ASP.NET MVC 5 Code first migration scheduler -
i can't seem view data on calendar. able save data scheduler/calendar , view data database table but, won't show in scheduler/calendar when refresh page. thinking wrong contentresult data() , can't figure out.
private applicationdbcontext _context; public calendarcontroller() { _context = new applicationdbcontext(); } protected override void dispose(bool disposing) { _context.dispose(); } public actionresult index() { var sched = new dhxscheduler(this); sched.skin = dhxscheduler.skins.terrace; sched.loaddata = true; sched.enabledataprocessor = true; var data = new schedulerajaxdata(_context.events.select(e => new { e.id, e.text, e.start_date, e.end_date })); return view(sched); } public contentresult data() { return (new schedulerajaxdata( _context.events .select(e => new { e.id, e.text, e.start_date, e.end_date }) ) ); } public contentresult save(int? id, formcollection actionvalues) { var action = new dataaction(actionvalues); var changedevent = dhxeventshelper.bind<event>(actionvalues); try { switch (action.type) { case dataactiontypes.insert: _context.events.add(changedevent); break; case dataactiontypes.delete: changedevent = _context.events.firstordefault(ev => ev.id == action.sourceid); _context.events.remove(changedevent); break; default:// "update" var target = _context.events.single(e => e.id == changedevent.id); dhxeventshelper.update(target, changedevent, new list<string> { "id" }); break; } _context.savechanges(); action.targetid = changedevent.id; } catch (exception a) { action.type = dataactiontypes.error; } return (new ajaxsaveresponse(action)); }
Comments
Post a Comment