public ActionResult CompleteAddCustomer(CustomerViewModel CustomerVM) { if(CustomerRepository.getInstance().GetAll().Where(x => x.Email.ToLower() == CustomerVM.Email.ToLower()).FirstOrDefault() == null) { CustomerRepository.getInstance().AddCustomer(CustomerVM); } return RedirectToAction("CompleteCheckout","Checkout", CustomerVM.Email); }
public List<CustomerViewModel> GetAll() { CustomerViewModels = new List<CustomerViewModel>(); List<Customer> Customers = new MoviesStoreProxy.Repository.Facade().GetCustomerRepository().ReadAll(); foreach (Customer cus in Customers) { CustomerViewModel newViewModel = new CustomerViewModel() { ID = cus.Id, FirstName = cus.FirstName, LastName = cus.LastName, Email = cus.Email.ToLower(), Address = cus.Address }; CustomerViewModels.Add(newViewModel); } return CustomerViewModels; }
public void AddCustomer(CustomerViewModel newViewCustomer) { Customer newCustomer = new Customer() { FirstName = newViewCustomer.FirstName, LastName = newViewCustomer.LastName, Address = newViewCustomer.Address, Email = newViewCustomer.Email, orders = new List<Order>() }; new MoviesStoreProxy.Repository.Facade().GetCustomerRepository().Add(newCustomer); }