Attaching Appointments to ResourceType

4 posts, 0 answers
  1. Xpress
    Xpress avatar
    6 posts
    Member since:
    Jan 2012

    Posted 21 Mar 2012 Link to this post

    I have an ObservableCollection that currently only has one ResourceType in it: Provider. I have 3 Providers in that ResourceType. I have a collection of Appointments that I have attached to the AppointmentSource.  When I did not have any ResourceType attached the appointments would appear in the scheduler just fine.  I have added the ResourceType and they are displaying correctly, but the appointments are not showing.  My collection of appointments is correctly populating still.  I have tried attaching the specific Provider I need to the Appointment's Resource, but I still cannot get them to show.  I am lost and would love any help that could be given.
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 26 Mar 2012 Link to this post

    Hello,

    When the ScheduleView is grouped by resources, the appointments should have a Resource assigned in order to be shown. I've attached a simple example to show how this works, please download the attachment and give it a try.

    Kind regards,
    Yana
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Xpress
    Xpress avatar
    6 posts
    Member since:
    Jan 2012

    Posted 26 Mar 2012 Link to this post

    Thanks for the example.  I did my best to follow the project you uploaded.  However, I am still not getting my appointments to show up under the resources.  If I don't have the resources, the appointments show up fine.  I'm going to throw out some code to see if you might be able to help more.

    This is where I load my Provider data model which inherits Resource.

    ProviderDataModel item = new ProviderDataModel();
    item.ProviderID = (reader["ProviderID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["ProviderID"]);
    item.ProviderFirstName = (reader["ProviderFirstName"] == DBNull.Value) ? string.Empty : reader["ProviderFirstName"].ToString();
    item.ProviderLastName = (reader["ProviderLastName"] == DBNull.Value) ? string.Empty : reader["ProviderLastName"].ToString();
    item.ProviderMiddleInitial = (reader["ProviderMiddleInitial"] == DBNull.Value) ? string.Empty : reader["ProviderMiddleInitial"].ToString();
    item.ProviderTitle = (reader["ProviderTitle"] == DBNull.Value) ? string.Empty : reader["ProviderTitle"].ToString();
    item.DisplayName = item.LastFirstName;
    item.ResourceName = item.ProviderID.ToString();
    item.ResourceType = "Providers";
     
    yield return item;

    Once it is loaded I then add them all into a ResourceType

    private void LoadResources()
    {
        ResourceTypes = new ObservableCollection<ResourceType>();
        ResourceType providerResourceType = new ResourceType("Providers");
        foreach (ProviderDataModel provider in Providers)
        {
            providerResourceType.Resources.Add(provider);
        }
        ResourceTypes.Add(providerResourceType);
    }

    Once I have the ResourceTypes collection loaded I then load my appointments

    public void LoadAppointments()
    {
        if (SessionVariables.Instance.CurrentFacility != null)
        {
            Appointments = new ObservableCollection<AppointmentDataModel>(appointmentDA.LoadAppointments(SessionVariables.Instance.CurrentFacility.FacilityID, ApplicationVariables.ConnectionStrings.ApplicationConfigurationConnectionString));
            foreach (AppointmentDataModel appointment in Appointments)
            {
                appointment.Patient = Patients.Where(x => x.PatientID == appointment.Patient.PatientID).FirstOrDefault() ?? new PatientDataModel();
                appointment.AppointmentType = AppointmentTypes.Where(x => x.AppointmentTypeID == appointment.AppointmentType.AppointmentTypeID).FirstOrDefault() ?? new AppointmentTypeDataModel();
                ProviderDataModel tempProvider = Providers.Where(x => x.ProviderID == appointment.AppointmentProviderScheduledID).FirstOrDefault();
                if (tempProvider != null)
                {
                    appointment.Resources.Add(tempProvider);
                }
            }
        }
    }

    I'm not at all sure what I'm doing wrong.  When I go through and check the properties of your example ResourceType collection and mine I can find no fundamental difference.  Thank you again for any help you can give.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 27 Mar 2012 Link to this post

    Hello,

    We're not sure what could be the reason for this issue in your project.  Please check whether the Start and End of your appointments are in the VisibleRange of the ScheduleView,

    We cannot help further without being able to reproduce and debug the problem locally. 

    Regards,
    Yana
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top