public ActionResult List(WebUser user, int page = 1) { try { var items = _payingItemService.GetList(i => i.UserId == user.Id && i.Date >= DbFunctions.AddDays(DateTime.Today, -2)).ToList(); var pItemToView = new PayingItemsCollectionModel() { PayingItems = items .OrderByDescending(i => i.Date) .ThenBy(x => x.Category.Name) .Skip((page - 1) * ItemsPerPage) .Take(ItemsPerPage), PagingInfo = new PagingInfo() { CurrentPage = page, ItemsPerPage = ItemsPerPage, TotalItems = items.Count } }; return(PartialView("_List", pItemToView)); } catch (ServiceException e) { throw new WebUiException($"Ошибка в контроллере {nameof(PayingItemController)} в методе {nameof(List)}", e); } catch (Exception e) { throw new WebUiException($"Ошибка в контроллере {nameof(PayingItemController)} в методе {nameof(List)}", e); } }
public async Task ActualizePlanItems(string userId) { var items = _pItemService.GetList() .Where(x => x.UserId == userId && x.Date.Month == DateTime.Today.Month && x.Date.Year == DateTime.Today.Year) .ToList(); var planItems = (await _planItemService.GetListAsync(userId)) .Where(x => x.Month.Month == DateTime.Today.Month && x.Month.Year == DateTime.Today.Year) .ToList(); foreach (var planItem in planItems) { planItem.SummFact = 0; await _planItemService.UpdateAsync(planItem); } await _planItemService.SaveAsync(); foreach (var payingItem in items) { foreach (var planItem in planItems) { if (planItem.CategoryId == payingItem.CategoryID) { planItem.SummFact += payingItem.Summ; await _planItemService.UpdateAsync(planItem); } } await _planItemService.SaveAsync(); } }
public IEnumerable <PayingItem> GetPayingItemsForLastYear(WebUser user) { try { return(_payingItemService.GetList() .Where(x => x.UserId == user.Id && x.Date <= DateTime.Today && x.Date >= DateTime.Today.AddYears(-1)) .ToList()); } catch (ServiceException e) { throw new WebUiHelperException( $"Ошибка в типе {nameof(PayingItemHelper)} в методе {nameof(GetPayingItemsForLastYear)}", e); } }
public ActionResult List(WebUser user, int page = 1) { PayingItemToView pItemToView; try { pItemToView = new PayingItemToView() { PayingItems = _payingItemService.GetList() .Where(i => (DateTime.Now.Date - i.Date) <= TimeSpan.FromDays(2) && i.UserId == user.Id) .OrderByDescending(i => i.Date) .ThenBy(x => x.Category.Name) .Skip((page - 1) * ItemsPerPage) .Take(ItemsPerPage) .ToList(), PagingInfo = new PagingInfo() { CurrentPage = page, ItemsPerPage = ItemsPerPage, TotalItems = _payingItemService.GetList() .Count(i => (DateTime.Now.Date - i.Date) <= TimeSpan.FromDays(2) && i.UserId == user.Id) } }; } catch (ServiceException e) { throw new WebUiException($"Ошибка в контроллере {nameof(PayingItemController)} в методе {nameof(List)}", e); } catch (Exception e) { throw new WebUiException($"Ошибка в контроллере {nameof(PayingItemController)} в методе {nameof(List)}", e); } return(PartialView("_List", pItemToView)); }
public IEnumerable <PayingItem> GetPayingItemsForLastYear(WebUser user) { var dateFrom = DateTime.Parse(DateTime.Today.ToString("Y", CultureInfo.CurrentCulture)); try { return(_payingItemService.GetList(x => x.UserId == user.Id && x.Date <= DbFunctions.AddMonths(dateFrom, 1) && x.Date >= DbFunctions.AddYears(dateFrom, -1)) .ToList()); } catch (ServiceException e) { throw new WebUiHelperException( $"Ошибка в типе {nameof(ReportControllerHelper)} в методе {nameof(GetPayingItemsForLastYear)}", e); } }
public async Task <List <PayItemSubcategories> > GetPayItemsWithSubcategoriesInDatesWeb(DateTime dateFrom, DateTime dateTo, IWorkingUser user, int typeOfFlowId) { try { var pItems = _payingItemService.GetList() //Отфильтрованный по дате,юзеру,типу список транзакций .Where(x => x.UserId == user.Id && x.Date >= dateFrom.Date && (x.Date <= dateTo.Date) && x.Category.TypeOfFlowID == typeOfFlowId) .ToList(); var payItemSubcategoriesList = new List <PayItemSubcategories>(); var ids = pItems.GroupBy(x => x.CategoryID) //Список ИД категорий за выбранный период .ToList(); ids.ForEach(id => payItemSubcategoriesList.Add(new PayItemSubcategories() //Наполняем у ViewModel свойства CategoryId { CategoryId = id.Key, CategorySumm = new OverAllItem(), ProductPrices = new List <ProductPrice>() })); var catNameGrouping = pItems //Наполняем список View Model и заполняем у каждого итема свойство CategorySumm .Where(x => x.UserId == user.Id && ((x.Date >= dateFrom.Date) && (x.Date <= dateTo.Date)) && x.Category.TypeOfFlowID == typeOfFlowId) .GroupBy(x => x.Category.Name) .ToList(); var i = 0; foreach (var item in payItemSubcategoriesList) { item.CategorySumm.Category = catNameGrouping[i].Key; item.CategorySumm.Summ = catNameGrouping[i].Sum(x => x.Summ); i++; } foreach (var item in payItemSubcategoriesList) { item.ProductPrices = await FillProductPrices(item.CategoryId, dateFrom, dateTo).ConfigureAwait(false); } return(payItemSubcategoriesList); } catch (ServiceException e) { throw new WebUiHelperException($"Ошибка в сервисе {nameof(PayItemSubcategoriesHelper)} в методе {nameof(GetPayItemsWithSubcategoriesInDatesWeb)} при обращении к БД", e); } }
public IEnumerable <PayingItem> GetList() { return(_payingItemService.GetList()); }