Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team

I have debug DHTMLX schedulor and date is not saving the db record, only on the view side and there are no browser issue, really need some help around this in order for this to save.

What I have tried:

C#
<pre>  // Calendar for Year.

    public class eNtsaCalendarEvents
    {
        [Key]
        public int id { get; set; }
        public string text { get; set; }
        public DateTime start_date { get; set; }
        public DateTime end_date { get; set; }
    }


public ActionResult eNtsaCourseEvents()
        {
            RegCoursesViewModel regCourses = new RegCoursesViewModel();
            var sched = new DHXScheduler(this);
            sched.Skin = DHXScheduler.Skins.Terrace;
            sched.LoadData = true;
            sched.EnableDataprocessor = true;
            sched.InitialDate = new DateTime(2020, 09, 17);
            return View(sched);
        }

        //GET:Data-Calendar.
        public ContentResult eNtsaData()
        {
            return (new SchedulerAjaxData(
               new eNtsaRegistration_2().Events
               .Select(e => new { e.id, e.text, e.start_date, e.end_date })
               )
               );
        }

        // Save-Data-Events.
        public ContentResult eNtsaSaveEvents(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            var changedEvent = DHXEventsHelper.Bind<eNtsaCalendarEvents>(actionValues);
            var entities = new eNtsaRegistration_2();

            try
            {
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        entities.Events.Add(changedEvent);
                        break;
                    case DataActionTypes.Delete:
                        changedEvent = entities.Events.FirstOrDefault(ev => ev.id == action.SourceId);
                        entities.Events.Remove(changedEvent);
                        break;
                    default:// "update"
                        var target = entities.Events.Single(e => e.id == changedEvent.id);
                        DHXEventsHelper.Update(target, changedEvent, new List<string> { "id" });
                        break;
                }
                entities.SaveChanges();
                action.TargetId = changedEvent.id;

            }
            catch (Exception e)
            {
                action.Type = DataActionTypes.Error;
            }
            return (new AjaxSaveResponse(action));

        }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900