private void SetCounter() { string DateNow = Infrastructure.Utility.Now.ToShortDateString(); Models.DaysReView oDaysReView = UnitOfWork.DaysReViewRepository.Get() .Where(p => p.Id == IdDay) .FirstOrDefault(); if (oDaysReView.DateSatistic.ToShortDateString() != DateNow) { ToDayCountReview--; } oDaysReView.TotalCount = ToDayCountReview; UnitOfWork.DaysReViewRepository.Update(oDaysReView); UnitOfWork.Save(); if (oDaysReView.DateSatistic.ToShortDateString() != DateNow) { YesterDayCountReview = ToDayCountReview; ToDayCountReview = 1; IdDay = System.Guid.NewGuid(); oDaysReView = new Models.DaysReView() { Id = IdDay, TotalCount = 1, DateSatistic = Infrastructure.Utility.Now }; UnitOfWork.DaysReViewRepository.Insert(oDaysReView); UnitOfWork.Save(); } }
private void IninitialParam() { try { System.Collections.Generic.List <Models.DaysReView> lstDaysReView = UnitOfWork.DaysReViewRepository.Get() .ToList(); if (lstDaysReView.Count > 0) { TotalCountReView = lstDaysReView.Sum(p => p.TotalCount); } else { TotalCountReView = 0; } string pp = Infrastructure.Utility.Now.AddDays(-1).ToShortDateString(); if (lstDaysReView.Where(p => p.DateSatistic.ToShortDateString() == Infrastructure.Utility.Now.AddDays(-1).ToShortDateString()).Count() > 0) { YesterDayCountReview = lstDaysReView.Where(p => p.DateSatistic.ToShortDateString() == Infrastructure.Utility.Now.AddDays(-1).ToShortDateString()).FirstOrDefault().TotalCount; } else { YesterDayCountReview = 0; } if (lstDaysReView.Where(p => p.DateSatistic.ToShortDateString() == Infrastructure.Utility.Now.ToShortDateString()).Count() > 0) { ToDayCountReview = lstDaysReView.Where(p => p.DateSatistic.ToShortDateString() == Infrastructure.Utility.Now.ToShortDateString()) .FirstOrDefault() .TotalCount; IdDay = lstDaysReView.Where(p => p.DateSatistic.ToShortDateString() == Infrastructure.Utility.Now.ToShortDateString()) .FirstOrDefault() .Id; } else { ToDayCountReview = 0; IdDay = System.Guid.NewGuid(); Models.DaysReView oDaysReView = new Models.DaysReView() { Id = IdDay, TotalCount = 0, DateSatistic = Infrastructure.Utility.Now }; UnitOfWork.DaysReViewRepository.Insert(oDaysReView); UnitOfWork.Save(); } OnlineCountReview = 0; ToDayCountReviewPage = 0; } catch (Exception ex) { throw (ex); } }