public ActionResult CreateNote(IEnumerable<NoteView> notes) { try { if (ModelState.IsValid) { var note = new Note { CtlNo = notes.FirstOrDefault().CtlNo, CtlName = notes.FirstOrDefault().CtlName }; if (TryUpdateModel(note)) { db.Note.Add(note); db.SaveChanges(); } } } catch (Exception ex) { }; return Json(null); }
public ActionResult UpdateNote(IEnumerable<NoteView> notes) { try { if (ModelState.IsValid) { var note = new Note { CtlNo = notes.FirstOrDefault().CtlNo, CtlName = notes.FirstOrDefault().CtlName }; if (TryUpdateModel(note)) { db.Entry(note).State = EntityState.Modified; db.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { }; return Json(null); }