public long CreateOrder(List <ProductInCart> productInCarts, Customer customer) { try { var idCustomer = _customerAdminRepository.AddCustomer(customer); var order = new Order() { IdCustomer = idCustomer }; var idOrder = _orderRepository.CreateOrder(order); foreach (var product in productInCarts) { var orderInformation = new OrderInformation() { IdOrder = idOrder, IdProduct = product.itemId, Quantity = product.quantity }; _orderRepository.CreateOrderInformation(orderInformation); } return(idOrder); } catch { return(0); } }
public long AddCustomer(Customer customer) { if (customer == null) { return(0); } var addCustomer = _customerAdminRepository.AddCustomer(customer); var idCustomer = addCustomer; return(idCustomer); }
public long AddCustomer(Customer customer) { var customersList = _customerAdminRepository.GetListCustomer(); if (customersList.Where(x => x.phone == customer.phone).Count() > 0) { var customerExits = customersList.Where(x => x.phone == customer.phone).FirstOrDefault(); return(customerExits.id); } return(_customerAdminRepository.AddCustomer(customer)); }
public long AddCustomer(string name, string phone) { var customersList = _customerAdminRepository.GetListCustomer(); if (customersList.Where(x => x.phone == phone).Count() > 0) { var customerExits = customersList.Where(x => x.phone == phone).FirstOrDefault(); return(customerExits.id); } var customer = new Customer() { Name = name, phone = phone }; var idCustomer = _customerAdminRepository.AddCustomer(customer); return(idCustomer); }