コード例 #1
0
ファイル: SlotController.cs プロジェクト: binhtv1997/Bus
 public ActionResult Get(string date)
 {
     try
     {
         var         list     = new List <SlotPriceVM>();
         List <Slot> slot     = _slotService.GetSlots().ToList();
         DateTime    dateFind = DateTime.Parse(date);
         int         j        = 1;
         for (int i = 0; i < slot.Count; i++)
         {
             double total = 0;
             var    ele   = _orderService.GetOrders().Where(o => o.SlotTakeId == slot.ElementAt(i).Id).Where(o => o.DateCreate.Date == dateFind.Date).ToList();
             foreach (var e in ele)
             {
                 total += e.TotalPrice;
             }
             SlotPriceVM s = new SlotPriceVM();
             s.Value = total / 1000;
             s.Key   = "Slot " + j;
             j++;
             list.Add(s);
         }
         return(Ok(list));
     }
     catch (Exception)
     {
         return(BadRequest(401));
     }
 }
コード例 #2
0
ファイル: SlotController.cs プロジェクト: binhtv1997/Bus
        public ActionResult GetNumber(string date)
        {
            try
            {
                var         list     = new List <SlotPriceVM>();
                List <Slot> slot     = _slotService.GetSlots().ToList();
                DateTime    dateFind = DateTime.Parse(date);
                int         i        = 1;
                foreach (var item in slot)
                {
                    var ele = _orderService.GetOrders().Where(o => o.SlotTakeId == item.Id).Where(o => o.DateCreate.Date == dateFind.Date).ToList();

                    SlotPriceVM s = new SlotPriceVM();
                    s.Value = ele.Count;
                    s.Key   = "Slot " + i;
                    i++;
                    list.Add(s);
                }
                return(Ok(list));
            }
            catch (Exception)
            {
                return(BadRequest(401));
            }
        }