public IActionResult Create(DepartmentDetailViewModel model) { // Check if is valid if (ModelState.IsValid) { // Push to database Department department = converter.ViewModelToModel(model); long id = departmentRepository.Insert(department); // Return detail view return(RedirectToAction("Details", new { id })); } return(View()); }
public IActionResult Create(TreatmentTypeDetailViewModel vm) { // Check if model is valid if (ModelState.IsValid) { // Push to database TreatmentType tt = converter.ViewModelToModel(vm); long id = repository.Insert(tt); // Return details page of just inserted record return(RedirectToAction("details", new { id })); } else { return(View(vm)); } }