Exemple #1
0
 [HttpGet("TongViewQuan")] // cập nhật điểm đánh giá cho quán
 public IActionResult TongViewQuan(string id)
 {                         //IDStore, Ratepoint
     try
     {
         View_Store view_Store = new View_Store();
         var        tongview   = view_Store.getByIDStore(id);
         return(Ok(tongview.Count));
     }
     catch
     {
         return(Ok("Error"));
     }
 }
Exemple #2
0
 [HttpGet("ThongKeTheoNam")]                                                      //Thống kê lượt view theo năm của quán
 public IActionResult ThongKeTheoNam(string id, int nam, double Lat, double Long) //IDStore
 {
     try{
         View_Store view_Store   = new View_Store();
         var        danhsachView = view_Store.getByIDStore(id);
         int[]      thongkenam   = new int[12];                 //1 năm 12 tháng, mảng tháng trong năm
         foreach (var item in danhsachView)
         {
             DateTime a = DateTime.Parse(item.Date);
             for (int i = 0; i < 12; i++)
             {
                 if (i == a.Month - 1 && nam == a.Year)
                 {
                     thongkenam[i] = thongkenam[i] + 1;
                 }
             }
         }
         return(Ok(thongkenam));
     }
     catch {
         return(Ok("Error"));
     }
 }
Exemple #3
0
 [HttpGet("ThongKeTheoThang")]                                                                 //thống kê lượt view theo tháng
 public IActionResult ThongKeTheoThang(string id, int thang, int nam, double Lat, double Long) //IDStore
 {
     try{
         View_Store view_Store   = new View_Store();
         var        danhsachView = view_Store.getByIDStore(id);        //Danh sach quán ăn
         int        songay       = view_Store.fun(thang, nam);         //số ngày của tháng
         int[]      thongkethang = new int[songay];                    //mang số ngày trong tháng
         foreach (var item in danhsachView)
         {
             DateTime a = DateTime.Parse(item.Date);
             for (int i = 0; i < songay; i++)
             {
                 if (i == a.Day - 1 && thang == a.Month && nam == a.Year) //nếu trùng thời gian thì tăng lượt đếm view
                 {
                     thongkethang[i] = thongkethang[i] + 1;               //(i=a.day-1 vì i bắt đầu = 0 ngày bắt đầu bằng 1)
                 }
             }
         }
         return(Ok(thongkethang));
     }
     catch {
         return(Ok("Error"));
     }
 }
Exemple #4
0
 [HttpGet("ThongKeTheoNgay")]                                                      //thống kế lượt view của quán theo từng ngày
 public IActionResult ThongKeTheoNgay(string id, int ngay, int thang, int nam)     //IdStore
 {
     try{
         View_Store view_Store   = new View_Store();                               //Model View_Store
         var        danhsachView = view_Store.getByIDStore(id);                    //Danh sách lượt xem
         int[]      thongkengay  = new int[24];                                    //Mãng 24 giờ trong 1 ngày
         foreach (var item in danhsachView)
         {
             DateTime a    = DateTime.Parse(item.Date);                            //thời gian của view
             TimeSpan Time = a.TimeOfDay;                                          //Biến timespan giúp phân chia hours, day, month, year
             for (int i = 0; i < 24; i++)
             {
                 if (i == Time.Hours && ngay == a.Day && thang == a.Month && nam == a.Year) //kiểm tra đúng ngày đúng giờ thêm view
                 {
                     thongkengay[i] = thongkengay[i] + 1;
                 }
             }
         }
         return(Ok(thongkengay));
     }
     catch {
         return(Ok("Error"));
     }
 }