Beispiel #1
0
        public IEnumerable <OperationDto> GetOperations(OperationsRequest request, ApplicationUser user)
        {
            Expression <Func <Operation, bool> > exp;

            exp = o => (o.CreatorId == user.Id) &&
                  (request.CategoriesIds == null || request.CategoriesIds.Contains(o.Category.Id)) &&
                  (request.CategoryType == null || o.Category.Type == request.CategoryType) &&
                  (request.From == null || o.Date > request.From) &&
                  (request.To == null || o.Date < request.To) &&
                  (request.LessThen == null || o.Amount < request.LessThen) &&
                  (request.MoreThen == null || o.Amount > request.MoreThen);

            return(this.dbContext.Operations
                   .Include(o => o.Category)
                   .Where(exp)
                   .Select(o => new OperationDto
            {
                Id = o.Id,
                Category = new CategoryDto
                {
                    Id = o.Category.Id,
                    CreatorId = o.Category.CreatorId,
                    Name = o.Category.Name,
                    IsStandart = o.Category.IsStandart,
                    Type = o.Category.Type
                },
                CategoryId = o.CategoryId,
                Amount = o.Amount,
                Date = o.Date,
                Notes = o.Notes
            }).ToList());
        }
Beispiel #2
0
        public async Task <IEnumerable <OperationDto> > GetAsync([FromQuery] OperationsRequest request)
        {
            var userName = User.Identity.Name;

            var appUser = await userManager.FindByNameAsync(userName);

            return(operationService.GetOperations(request, appUser));
        }
 public OperationsViewModel Get(OperationsRequest request)
 {
     return new OperationsViewModel();
 }