public CustomerViewModel(Customer customer) { Id = customer.Id; FirstName = customer.FirstName; LastName = customer.LastName; EmailAddress = customer.ContactDetails.EmailAddress; HomePhoneNumber = customer.ContactDetails.HomePhoneNumber; }
public bool AddCustomer(Customer customer) { try { m_context.Customers.Add(customer); return true; } catch (Exception) { return false; } }
public ActionResult NewCustomer(CustomerViewModel customerModel) { if (ModelState.IsValid) { Customer customer = new Customer() { FirstName = customerModel.FirstName, LastName = customerModel.LastName, ContactDetails = new ContactDetails() { EmailAddress = customerModel.EmailAddress, HomePhoneNumber = customerModel.HomePhoneNumber } }; m_repository.AddCustomer(customer); m_repository.Save(); return Redirect("~/Home/Customers"); } else { return View(customerModel); } }