public ActionResult Create([Bind(Include = "Id,Email,FirstName,LastName,Major,Year")] Tutor tutor) { if (ModelState.IsValid) { db.Tutors.Add(tutor); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tutor)); }
public ActionResult Create([Bind(Include = "Id,Area,Number,Description")] Course course) { if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public ContentResult Save(int?id, FormCollection actionValues) { var action = new DataAction(actionValues); var changedEvent = DHXEventsHelper.Bind <Event>(actionValues); var entities = new DBOModel(); 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 a) { action.Type = DataActionTypes.Error; } return(new AjaxSaveResponse(action)); }