Re-Assign Resource to SqlAppointment Manually

8 posts, 1 answers
  1. Azib
    Azib avatar
    7 posts
    Member since:
    Jun 2012

    Posted 10 Jan 2013 Link to this post

    Hello

    I am trying to evaluate Scheduleview with OpenAccess.

    My Scenario seems to be simple. 
    - Create an Appointment
    - Assign Resources
    - Update Resource

    Since WCF Ria doesnt support many to many relationship and i cannot find any help for M2M4Ria with OpenAccess, i decided to do all this manually.

    I followed the table template according to guideline for working with database with Scheduleview explained here, I modified the Model to work with WCF and recreate the link table as described here. Now i am successfully able to create a new SqlAppointment, Assign Resource to an Appointment via codebehind. (btw, i created a saperate page just to assign resources to Appointments)

    Problem : now the problem is, when i want to update the resource, i cant seem to find a way to do it. i guessed i need to remove the 'SqlAppointmentResources' relation entry and then submit changes, but submit change takes forever and then come back with error of timeout.

    Is there anyway we can work with OpenAccess with Scheduleview? can you refer me any links which can help implement M2M4Ria with OpenAccess? i am asking this because in your example with Scheduleview you used M2M4Ria but with Entity Framework. Does OpenAccess even support this kind of scenario?

    Thanks for your help
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 15 Jan 2013 Link to this post

    Hi Azib,

    We updated our example with ScheduleView with database to work without M2M4Ria - we managed to work-around the limitation of WCF RIA Services by using an additional property which forces EF to create Many-To-Many tables. I have attached the updated example to this thread (we will update the CL and the articles as well), so you can try it and use the approach with OpenAccess ORM. 

    I hope this will be helpful.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Azib
    Azib avatar
    7 posts
    Member since:
    Jun 2012

    Posted 15 Jan 2013 Link to this post

    Hello Yana

    Thanks for your help, i will try it and will update the thread. It will be very helpful if you can update this thread once you update the CL.

    Regards

    Azib
  5. Azib
    Azib avatar
    7 posts
    Member since:
    Jun 2012

    Posted 21 Jan 2013 Link to this post

    Hey Yana

    Thanks for the solution, well it does add new appointments, thx. But when it comes to Custom Appointment, really having big tough time .. may be its me ....
    - cannot add custom properties or should i say cannot figure out how to add custom properties
    - i followed the example for custom appointment, but there is no where it shows how to then save back to database.
    - i tried loading appointments in ScheduleviewRepository, but when i load from database, or Ria Context, it tells me that SqlAppointment cannot cast to T type. ggggrrrrr


    Yana please help, i ll appreciate if you can show me the right path.

    Regards
  6. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 24 Jan 2013 Link to this post

    Hello Azib,

    I will explain step by step how to add a custom property:

    1. First you will need to add the property in the SqlAppointment table in the database.
    2. Then you will have to generate again the Entity Model and and the Domain Service as now your database will be different from the one in the example. Check here for more details regarding this step.
    3. Add the additional code from our ScheduleViewDomainService.cs to your newly created DomainService class.
    4. Here is the tricky part which I guess you've missed -  SqlAppointment is shared between the generated SqlAppointment class in the Web project and our SqlAppointment class in the Silverlight project (which implements IAppointment). The generated SqlAppointment already has JobId property (as it comes from the database), so all you need to do is to go to our SqlAppointment.cs (in the Models folder in the SL project), find CopyFrom method and add an additional line for the JobId property:

    void ICopyable<IAppointment>.CopyFrom(IAppointment other)
    {
        this.IsAllDayEvent = other.IsAllDayEvent;
        this.Start = other.Start;
        this.End = other.End;
        this.Subject = other.Subject;
                 
     
        var otherAppointment = other as SqlAppointment;
        if (otherAppointment == null)
            return;
     
        this.JobId = otherAppointment.JobId;
        this.CategoryID = otherAppointment.CategoryID;
        this.TimeMarker = otherAppointment.TimeMarker;
        this.RecurrenceRule = other.RecurrenceRule == null ? null : other.RecurrenceRule.Copy() as SqlRecurrenceRule;
        this.RecurrencePattern = otherAppointment.RecurrencePattern;
     
        this.Resources.Clear();
        this.Resources.AddRange(otherAppointment.Resources);
     
        this.Body = otherAppointment.Body;
    }

    Now the property should be saved without a problem.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Azib
    Azib avatar
    7 posts
    Member since:
    Jun 2012

    Posted 24 Jan 2013 Link to this post

    Dear Yana

    That solved my problem. Telerik Support is still the BEST in industry. Bravo to your team.

    Thx

    Azib
  8. mike okon
    mike okon avatar
    40 posts
    Member since:
    Dec 2009

    Posted 16 May 2013 Link to this post

    Hi

    This looked like what I have been needing the last 5 months. Just to me it seems incomplete.  I do not see how I can Get the value back into the Database from the edit appointment dialog window. Can you please provide a working example with one custom field. A simple string will do. If possible a combobox which holds a list of names.

    regards
    mike
  9. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 20 May 2013 Link to this post

    Hi Mike,

    We do not have such an example at hand. Basically, the  DataContext of the EditAppointmentDialog is of type AppointmentDialogViewModel, so in the dialog you can bind the controls to any of the properties of the custom appointment through the Occurrence.Appointment property of the ViewModel, you can check this topic for more details.
     
    How exactly are the items for the ComboBox saved in the database? Is it possible to open a support ticket and send us a simple version of your project, so we to be able to test the exact case?

    Greetings,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner