コード例 #1
0
 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);
     }
 }
コード例 #2
0
        public long AddCustomer(Customer customer)
        {
            if (customer == null)
            {
                return(0);
            }
            var addCustomer = _customerAdminRepository.AddCustomer(customer);
            var idCustomer  = addCustomer;

            return(idCustomer);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }