public ActionResult Edit(WorkTypeView workTypeModel) { if (ModelState.IsValid) { IWorkTypesRepository workTypesRepository = new WorkTypesRepository(db); WorkType workType = workTypesRepository.GetWorkTypeByPK((int)workTypeModel.WorkTypePK); workTypeModel.ConvertTo(workTypeModel, workType); workTypesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", workType.WorkTypePK); return(RedirectToAction("Index", "WorkType")); } else { return(View(workTypeModel)); } }
public ActionResult Add(WorkTypeView workTypeView) { if (ModelState.IsValid) { IWorkTypesRepository workTypesRepository = new WorkTypesRepository(db); WorkType workType = new WorkType(); workTypeView.ConvertTo(workTypeView, workType); workTypesRepository.Add(workType); workTypesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", workType.WorkTypePK); return(RedirectToAction("Index", "WorkType")); } else { return(View(workTypeView)); } }