public virtual IActionResult Create(TaskGroupModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageTaskGroup)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var item = model.ToEntity <TaskGroup>(); //ensure we have "/" at the end _taskGroupService.InsertTaskGroup(item); //activity log _customerActivityService.InsertActivity("AddNewTaskGroup", string.Format(_localizationService.GetResource("ActivityLog.AddNewTaskGroup"), item.Id), item); SuccessNotification(_localizationService.GetResource("AppWork.Contracts.TaskGroup.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = item.Id }) : RedirectToAction("List")); } //prepare model model = _taskModelFactory.PrepareTaskGroupModel(model, null); //if we got this far, something failed, redisplay form return(View(model)); }
public virtual IActionResult Edit(TaskGroupModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageTaskGroup)) { return(AccessDeniedView()); } //try to get a store with the specified id var item = _taskGroupService.GetTaskGroupById(model.Id); if (item == null) { return(RedirectToAction("List")); } if (ModelState.IsValid) { item = model.ToEntity(item); _taskGroupService.UpdateTaskGroup(item); //activity log _customerActivityService.InsertActivity("EditTaskGroup", string.Format(_localizationService.GetResource("ActivityLog.EditTaskGroup"), item.Id), item); SuccessNotification(_localizationService.GetResource("AppWork.Contracts.TaskGroup.Updated")); return(continueEditing ? RedirectToAction("Edit", new { id = item.Id }) : RedirectToAction("List")); } //prepare model model = _taskModelFactory.PrepareTaskGroupModel(model, item, true); //if we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Edit(TaskGroupModel model) { var taskGroup = _taskGroupRepository.GetById(model.Id); if (ModelState.IsValid) { taskGroup = model.ToEntity(taskGroup); //always set IsNew to false when saving taskGroup.IsNew = false; _taskGroupRepository.Update(taskGroup); //commit all changes this._dbContext.SaveChanges(); //notification SuccessNotification(_localizationService.GetResource("Record.Saved")); return(new NullJsonResult()); } else { return(Json(new { Errors = ModelState.SerializeErrors() })); } }