示例#1
0
 [HttpGet("ThongKeTheoBusinessType")]                                                        //Thống kê số quán theo từng loại mô hình quán
 public IActionResult ThongKeTheoBusinessType()
 {
     try{
         BusinessType businessType         = new BusinessType();                             //Danh sách loại kinh doanh
         var          danhsachbusinessType = businessType.getAll();
         List <BienThongKeBusinessType> bienThongKeQuans = new List <BienThongKeBusinessType>();
         foreach (var item in danhsachbusinessType)
         {
             BienThongKeBusinessType bienThongKes = new BienThongKeBusinessType();
             bienThongKes.BusinessTypeID    = item.BusinessTypeID;
             bienThongKes.BusinessTypetName = item.BusinessTypeName;
             bienThongKeQuans.Add(bienThongKes);                                             // Thêm thông tin loại kinh doanh vào danh sách thống kê
         }
         Store store          = new Store();
         var   danhsachquanan = store.getAll(0, 0);
         foreach (var item in bienThongKeQuans)
         {
             int dem = 0;
             foreach (var itemquan in danhsachquanan)
             {
                 if (itemquan.BusinessTypeID == item.BusinessTypeID)
                 {
                     dem++;                                                                 // Nếu BusinessTypeID trùng biến đếm tăng
                 }
             }
             item.SoQuan = dem;
         }
         return(Ok(bienThongKeQuans));
     }
     catch
     {
         return(Ok("Error"));
     }
 }
示例#2
0
 [HttpGet("GetAll")]                                     //Lấy tất cả dữ liệu loại hình kinh doanh quán ăn
 public IActionResult GetAll()
 {
     try{
         BusinessType danhsach = new BusinessType();     //Khai báo biến Model
         return(Ok(danhsach.getAll()));                  //trả về danh sách dữ liệu
     }
     catch {
         return(Ok("Error"));
     }
 }