public ActionResult Edit(CalendarModel model) { var calendar = _calendarRepository.GetById(model.Id); if (ModelState.IsValid) { calendar = model.ToEntity(calendar); //always set IsNew to false when saving calendar.IsNew = false; //update attributes _calendarRepository.Update(calendar); //commit all changes this._dbContext.SaveChanges(); //notification SuccessNotification(_localizationService.GetResource("Record.Saved")); return(new NullJsonResult()); } else { return(Json(new { Errors = ModelState.SerializeErrors() })); } }