Ejemplo n.º 1
0
 public CustomerViewModel(Customer customer)
 {
     Id = customer.Id;
     FirstName = customer.FirstName;
     LastName = customer.LastName;
     EmailAddress = customer.ContactDetails.EmailAddress;
     HomePhoneNumber = customer.ContactDetails.HomePhoneNumber;
 }
Ejemplo n.º 2
0
        public bool AddCustomer(Customer customer)
        {
            try
            {
                m_context.Customers.Add(customer);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }