public ActionResult GetDataObservation(int deviceId)
        {
            List <DataObservationModel> data = new List <DataObservationModel>();
            DateTime from = DateTime.Today;
            DateTime to   = DateTime.Now;

            data = dataObservationMongoService.GetDataPagingByDeviceId(from, to, deviceId, 0, 50, out int total).Select(i => new DataObservationModel
            {
                NameSite   = sitesService.sitesResponsitory.GetAll().Where(j => j.DeviceId == i.Device_Id).FirstOrDefault().Name,
                DateCreate = i.DateCreate,
                BTI        = i.BTI,
                BTO        = i.BTO,
                BHU        = i.BHU,
                BWS        = i.BWS,
                BAP        = i.BAP,
                BAV        = i.BAV,
                BAF        = i.BAF,
                BAC        = i.BAC,
            }).ToList();
            return(PartialView("_DataObservationParialView", data));
        }
        public ActionResult Management(int page = 1, int pageSize = 50, string title = "", int?areaId = null, string fromDate = "", string toDate = "", int?siteID = null)
        {
            ViewBag.Title         = "";
            ViewBag.MessageStatus = TempData["MessageStatus"];
            ViewBag.Message       = TempData["Message"];
            if (pageSize == 1)
            {
                pageSize = CMSHelper.pageSizes[0];
            }
            @ViewBag.PageSizes = CMSHelper.pageSizes;

            int CurrentUserId = WebMatrix.WebData.WebSecurity.CurrentUserId;
            int?groupId       = userProfileService.userProfileResponsitory.Single(CurrentUserId).Group_Id;

            ViewBag.lstTram = sitesService.GetBygroupId(groupId).ToList();
            string   userName = User.Identity.Name;
            int      skip     = (page - 1) * pageSize;
            DateTime from     = DateTime.Today;
            DateTime to       = from.AddDays(1);

            if (fromDate != "")
            {
                try
                {
                    from = Convert.ToDateTime(fromDate);
                    to   = Convert.ToDateTime(toDate);
                }
                catch { }
            }
            List <DataObservationModel> list = new List <DataObservationModel>();
            int totalRows = 0;

            if (siteID.HasValue)
            {
                int deviceId = sitesService.sitesResponsitory.Single(siteID).DeviceId.Value;
                list = dataObservationMongoService.GetDataPagingByDeviceId(from, to, deviceId, skip, pageSize, out int total).OrderByDescending(i => i.DateCreate).Select(x => new DataObservationModel
                {
                    BTI        = x.BTI,
                    BTO        = x.BTO,
                    BHU        = x.BHU,
                    BWS        = x.BWS,
                    BAP        = x.BAP,
                    BAV        = x.BAV,
                    BAC        = x.BAC,
                    BAF        = x.BAF,
                    NameSite   = sitesService.sitesResponsitory.GetAll().Where(i => i.DeviceId == x.Device_Id).FirstOrDefault().Name,
                    DateCreate = x.DateCreate
                }).ToList();
                totalRows = total;
            }
            else
            {
                list = dataObservationMongoService.GetDataPaging(from, to, skip, pageSize, out int total).OrderByDescending(i => i.DateCreate).Select(x => new DataObservationModel
                {
                    BTI        = x.BTI,
                    BTO        = x.BTO,
                    BHU        = x.BHU,
                    BWS        = x.BWS,
                    BAP        = x.BAP,
                    BAV        = x.BAV,
                    BAC        = x.BAC,
                    BAF        = x.BAF,
                    NameSite   = sitesService.sitesResponsitory.GetAll().Where(i => i.DeviceId == x.Device_Id).FirstOrDefault().Name,
                    DateCreate = x.DateCreate
                }).ToList();
                totalRows = total;
            }



            #region Hiển thị dữ liệu và phân trang
            DataObservationViewModel viewModel = new DataObservationViewModel
            {
                DataO      = new StaticPagedList <DataObservationModel>(list, page, pageSize, totalRows),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = totalRows
                },
                From = from,
                To   = to,
            };
            #endregion
            return(View(viewModel));
        }