Gcobani Mkontwana

Gcobani Mkontwana

  • 1.1k
  • 1.1k
  • 66.4k

Timeshechelor not saving to the database record

Sep 30 2020 8:13 AM
Hi Team
 
My time schedulor is not saving to the database record, its only creating the events only when a user creates them. Need some help as to why, even if i refresh the browser those events are not being saved.
  1. public ActionResult eNtsaCourseEvents()  
  2.        {  
  3.            RegCoursesViewModel regCourses = new RegCoursesViewModel();  
  4.            var sched = new DHXScheduler(this);  
  5.            sched.Skin = DHXScheduler.Skins.Terrace;  
  6.            sched.LoadData = true;  
  7.            sched.EnableDataprocessor = true;  
  8.            sched.InitialDate = new DateTime(2020, 09, 17);  
  9.            return View(sched);  
  10.        }  
  11.   
  12.        //GET:Data-Calendar.  
  13.        public ContentResult eNtsaData()  
  14.        {  
  15.            return (new SchedulerAjaxData(  
  16.               new eNtsaRegistration_2().Events  
  17.               .Select(e => new { e.id, e.text, e.start_date, e.end_date })  
  18.               )  
  19.               );  
  20.        }  
  21.   
  22.        // Save-Data-Events.  
  23.        public ContentResult eNtsaSaveEvents(int? id, FormCollection actionValues)  
  24.        {  
  25.            var action = new DataAction(actionValues);  
  26.            var changedEvent = DHXEventsHelper.Bind<eNtsaCalendarEvents>(actionValues);  
  27.            var entities = new eNtsaRegistration_2();  
  28.   
  29.            try  
  30.            {  
  31.                switch (action.Type)  
  32.                {  
  33.                    case DataActionTypes.Insert:  
  34.                        entities.Events.Add(changedEvent);  
  35.                        break;  
  36.                    case DataActionTypes.Delete:  
  37.                        changedEvent = entities.Events.FirstOrDefault(ev => ev.id == action.SourceId);  
  38.                        entities.Events.Remove(changedEvent);  
  39.                        break;  
  40.                    default:// "update"  
  41.                        var target = entities.Events.Single(e => e.id == changedEvent.id);  
  42.                        DHXEventsHelper.Update(target, changedEvent, new List<string> { "id" });  
  43.                        break;  
  44.                }  
  45.                entities.SaveChanges();  
  46.                action.TargetId = changedEvent.id;  
  47.   
  48.            }  
  49.            catch (Exception e)  
  50.            {  
  51.                action.Type = DataActionTypes.Error;  
  52.            }  
  53.            return (new AjaxSaveResponse(action));  
  54.   
  55.        }  
 

Answers (4)