public BaseResponse <Bill> ListAll()
        {
            var list = new BillDAO().GetAllBill();

            foreach (var item in list)
            {
                var deliverydetail = new DeliveryDAO().Get(item.DeliveryDetailID);
                item.Name   = deliverydetail.Name;
                item.Phone  = deliverydetail.PhoneNumber;
                item.Adress = deliverydetail.Adress;
                double  value = 0;
                decimal price = new BillDetailDAO().TotalPrice(item.ID);
                if (!string.IsNullOrEmpty(item.DiscountCode))
                {
                    price = price - price * (decimal)(new DiscountDAO().Get(item.DiscountCode).Value);
                    value = (new DiscountDAO().Get(item.DiscountCode).Value) * 100;
                }
                item.DiscountValue = value;
                item.TotalPrice    = price;
            }
            StatusResponse      status   = list != null ? StatusResponse.Success : StatusResponse.Fail;
            BaseResponse <Bill> response = new BaseResponse <Bill>(status, "", list);

            return(response);
        }
Beispiel #2
0
        public decimal [] GetRevenueMonth()
        {
            decimal[]   month = new decimal[13];
            List <Bill> bills = GetAllBill();

            for (int i = 0; i < 12; i++)
            {
                month[i] = 0;
            }
            foreach (var item in bills)
            {
                List <BillDetail> list    = new BillDetailDAO().GetBillDetail(item.ID);
                decimal           revenue = 0;
                foreach (var detail in list)
                {
                    var product = new ProductDAO().Get(detail.ProductID);
                    revenue += detail.Quantities * product.Price;
                }
                var index = item.CreatedDate.Month;
                month[index - 1] += revenue;
            }
            return(month);
        }