i can't link my json result with the schedule

i tried to follow this docs 
https://help.syncfusion.com/xamarin/sfschedule/getting-started

but i'm not too good in english 

please help me out thank you

This is my code :  



public partial class Scheduler : ContentPage
{

        public class Meta
        {
            public string service { get; set; }
            public int row_count { get; set; }
            public string year { get; set; }
            public string student_key_name { get; set; }
            public string student_key_value { get; set; }
            public object group_key_value { get; set; }
            public object teacher_key_name { get; set; }
            public object teacher_key_value { get; set; }
        }

        public class Event
        {
            public string descrption { get; set; }
            public string date_start { get; set; }
            public string date_end { get; set; }
            public string salle { get; set; }
            public string professeur { get; set; }
            public string semaine { get; set; }
            public string jours { get; set; }
            public string module { get; set; }
            public string groupe_de_classe { get; set; }
            public string type { get; set; }
            public string remarque { get; set; }
            public string autre_professeur { get; set; }
            public string autre_groupe { get; set; }
            public string nom { get; set; }
            public string event_id { get; set; }
        }

        public class Data
        {
            public List<Event> events { get; set; }
        }

        public class RootObject
        {
            public Meta meta { get; set; }
            public Data data { get; set; }
        }
        public Scheduler ()
{
InitializeComponent ();
            Sched();
            Rest();
        }


        public void Sched()
        {
            schedule = new SfSchedule();
            new ContentPage { Content = schedule };
            schedule.FirstDayOfWeek = (int)DayOfWeek.Tuesday;


            ScheduleAppointmentMapping dataMapping = new ScheduleAppointmentMapping();
            
            dataMapping.EndTimeMapping = "date_end";
            dataMapping.StartTimeMapping = "date_start";
            dataMapping.SubjectMapping = "remarque";
            schedule.AppointmentMapping = dataMapping;




        }



        public void Rest()
        {
            Restepf Rest_3 = new Restepf();
            Restepf Student = new Restepf();
            IRestResponse result_Student = Rest_3.Student("[email protected]");
            var JResponse_Student = JsonConvert.DeserializeObject<dynamic>(result_Student.Content);
             // this is the Json Result 
            Console.WriteLine("JSON RESULT-->" + JResponse_Student);

        }

1 Reply

DY Deivaselvan Y Syncfusion Team August 30, 2018 05:27 PM UTC

Hi Soufiane,

Thank you for contacting Syncfusion support.

We have checked with the provided information. In SfSchedule, you 
can bind appointments to the schedule control form other sources using appointment mapping technique. We have prepared a simple sample to bind data to the SfSchedule form JSON data. Kindly refer the sample below,  
  
Sample: Sample  
 
In the above sample, we have stored the data in string format in JSONData model and then we have converted and stored in custom appointment Meeting model, then it is mapped to the schedule using ScheduleAppointmentMapping. Kindy refer the code snippet below,  
  
    public class JSONData  
    {  
        public string Subject { get; set; }  
        public string StartTime { get; set; }  
        public string EndTime { get; set; }  
        public string IsAllDay { get; set; }  
        public string Background { get; set; }  
    }  
  
  
    public class Meeting  
    {  
        public string EventName { get; set; }  
        public DateTime From { get; set; }  
        public DateTime To { get; set; }  
        public bool AllDay { get; set; }  
        public Color Color { get; set; }  
    }  
  
  
        public ObservableCollection<Meeting> Meetings  { getset; }  
  
        private string JsonData =  
            "[{\"Subject\": \"General Meeting\",\"StartTime\": \"8 / 30 / 2018 3:00:00 PM\",\"EndTime\":\"8 / 30 / 2018 4:00:00 PM\",\"Background\":\"#5944dd\", \"IsAllDay\":\"True\"}, " +  
            "{\"Subject\": \"Plan Execution\",\"StartTime\": \"8 / 22 / 2018 10:00:00 AM\",\"EndTime\":\"8 / 22 / 2018 11:00:00 AM\",\"Background\":\"#ff0000\", \"IsAllDay\":\"False\"}," +  
            "{\"Subject\": \"Performance Check\",\"StartTime\": \"8 / 17 / 2018 5:00:00 PM\",\"EndTime\":\"8 / 17 / 2018 6:00:00 PM\",\"Background\":\"#5944dd\", \"IsAllDay\":\"False\"}," +  
            "{\"Subject\": \"Consulting\",\"StartTime\": \"8 / 03 / 2018 9:00:00 AM\",\"EndTime\":\"8 / 03 / 2018 5:00:00 PM\",\"Background\":\"#ed0497\", \"IsAllDay\":\"True\"}," +  
            "{\"Subject\": \"Yoga Therapy\",\"StartTime\": \"8 / 27 / 2018 10:00:00 AM\",\"EndTime\":\"8 / 27 / 2018 11:00:00 AM\",\"Background\":\"#ff0000\", \"IsAllDay\":\"False\"}," +  
            "{\"Subject\": \"Project Plan\",\"StartTime\": \"8 / 30 / 2018 3:00:00 PM\",\"EndTime\":\"8 / 30 / 2018 4:00:00 PM\",\"Background\":\"#ed0497\", \"IsAllDay\":\"False\"} ]" 
  
        public ViewModel()  
        {  
           Meetings = new ObservableCollection<Meeting>();  
              
            var jsonDataCollection = JsonConvert.DeserializeObject<List<JSONData>>(JsonData);  
  
            foreach (var data in jsonDataCollection)  
            {  
                Meetings.Add(new Meeting()  
                {  
                    EventName = data.Subject,  
                    From = Convert.ToDateTime(data.StartTime),  
                    To = Convert.ToDateTime(data.EndTime),  
                    Color = Color.FromHex(data.Background),  
                    AllDay = Convert.ToBoolean(data.IsAllDay)  
                });  
            }  
        }  
    }  

Please let us know if you need further assistance on this. 

Regards,
Deivaselvan 


Loader.
Up arrow icon