public ActionResult Edit(UserTaskManageViewModel model) { if (ModelState.IsValid) { var application = userTaskRepository.GetById(model.Id); if (application == null) { throw new ArgumentException(string.Format("UserTask with Id [{0}] does not exist", model.Id)); } try { model.ToDalEntity(application); userTaskRepository.UpdateAndSubmit(application); base.SetSuccessMessage("The user task [{0}] has been updated.", application.Name); return(RedirectToAction("Index")); } catch (Exception ex) { base.SetErrorMessage("Whoops! Couldn't update the application. The error was [{0}]", ex.Message); } } return(View(model)); }
public ActionResult Create(UserTaskManageViewModel model) { if (ModelState.IsValid) { try { var userTask = model.ToDalEntity(); userTaskRepository.InsertAndSubmit(userTask); base.SetSuccessMessage("The userTask [{0}] has been created.", userTask.Name); return(RedirectToAction("Index")); } catch (Exception ex) { base.SetErrorMessage("Whoops! Couldn't create the new userTask. The error was [{0}]", ex.Message); } } return(View(model)); }