public static DepartmentModel FromDomainModel(Department department) { if (department == null) return null; return new DepartmentModel() { ID = department.ID, Address = department.Address, Name = department.Name, PhoneNumber = department.PhoneNumber, }; }
public ActionResult DepartmentModelFormView(DepartmentModel departmentModel) { if (ModelState.IsValid) { Autorent.Modules.Administration.Department newDepartment = new Department(); if (Guid.Empty.Equals(departmentModel.ID)) { departmentModel.ID = Guid.NewGuid(); departmentModel.AssignTo(newDepartment); DepartmentAPI.CreateDepartment(newDepartment); } else { departmentModel.AssignTo(newDepartment); ///TODO EDIT DEPARTMENT API } return RedirectToAction("Department", "Administration"); } return View(departmentModel); }