Ejemplo n.º 1
0
        public decimal GetOrderPrice(Order order)
        {
            _orderService = new DAL.OrderService();

            _customerService = new DAL.CustomerService();

            bool isNewCustomer = _orderService.IsNewCustomer(order.CustomerId);

            Customer customer = _customerService.GetCustomer(order.CustomerId);

            var orderDate = order.OrderDate.DayOfWeek;

            if (!string.IsNullOrWhiteSpace(order.Coupon))
            {
                return(order.Quantity * Convert.ToDecimal(ConfigurationManager.AppSettings["CouponCost"]));
            }
            else if (isNewCustomer)
            {
                return(order.Quantity * Convert.ToDecimal(ConfigurationManager.AppSettings["NewCustomer"]));
            }
            else if (customer.IsGoldRatedCustomer && !isNewCustomer)
            {
                return(order.Quantity * Convert.ToDecimal(ConfigurationManager.AppSettings["GoldRatedCustomerCost"]));
            }
            else if (orderDate == DayOfWeek.Saturday || orderDate == DayOfWeek.Sunday)
            {
                return(order.Quantity * Convert.ToDecimal(ConfigurationManager.AppSettings["WeekendCost"]));
            }
            else
            {
                return(_orderService.GetOrderPrice(order) + (basePrice * order.Quantity));
            }
        }
Ejemplo n.º 2
0
 public int SaveCustomer(Customer customer)
 {
     _customerService = new DAL.CustomerService();
     return(_customerService.SaveCustomer(customer));
 }
Ejemplo n.º 3
0
 public int ValidateCustomer(Customer customer)
 {
     _customerService = new DAL.CustomerService();
     return(_customerService.ValidateCustomer(customer));
 }