public static CustomersModel EntityToModel(this Customers entity, bool virtualActive = false) { try { CustomersModel model = new CustomersModel() { Description = entity.Description, Name = entity.Name, BloodGroup = entity.BloodGroup, DateOfBirth = entity.DateOfBirth, EmailAddress = entity.EmailAddress, IdentificationNumber = entity.IdentificationNumber, Address = entity.Address, IsMale = entity.IsMale, IsMarried = entity.IsMale, NationalityId = entity.NationalityId, PhoneNumber = entity.PhoneNumber, Surname = entity.Surname, Id = entity.Id }; if (virtualActive) { model.Nationality = entity.Nationality; model.Sales = entity.Sales; model.StayingInRoom = entity.StayingInRoom; } return model; } catch (Exception) { return new CustomersModel(); } }
public ActionResult CustomerEdit(CustomersModel customersModel) { Customers customers = customersModel.ModelToEnity(); _serviceCustomers.Update(customers); return RedirectToAction("CustomerEdit"); }
public ActionResult CustomerInsert(CustomersModel customersModel) { if (ModelState.IsValid) { _serviceCustomers.Insert(customersModel.ModelToEnity()); } return RedirectToAction("CustomerList"); }