public async Task <List <UnifiedAccountOperation> > GetTransformedUnifiedOperations(Guid accountId)
        {
            var result = await GetCacheEntry(accountId).GetOrAddAsync(
                () => _operationsRepository.GetAll(accountId));

            return(result);
        }
Beispiel #2
0
 public PagedList <OperationResponse> GetOperations(OperationGetRequest response, Guid userId)
 => PagedList <OperationResponse> .ToPagedList(_repository.GetAll()
                                               .Where(o => o.OperationCategory.UserId == userId)
                                               .Where(o => o.ResourceId == (response.ResourceId ?? o.ResourceId))
                                               .Where(o => o.OperationCategoryId == (response.OperationCategoryId ?? o.OperationCategoryId))
                                               .Where(o => o.IsIncome == (response.IsIncome ?? o.IsIncome))
                                               .Where(o => o.Name == (response.Name ?? o.Name))
                                               .Where(o => o.Value >= (response.MinValue ?? o.Value))
                                               .Where(o => o.Value <= (response.MaxValue ?? o.Value))
                                               .Where(o => o.OccuredAt >= (response.MinOccuredAt ?? o.OccuredAt))
                                               .Where(o => o.OccuredAt <= (response.MinOccuredAt ?? o.OccuredAt))
                                               .OrderByDescending(o => o.OccuredAt)
                                               .Select(r => _mapper.Map <OperationResponse>(r)),
                                               response.Page, response.Limit);
Beispiel #3
0
        public async Task DeleteResource(Guid resourceId)
        {
            var cyclicOperations = _cyclicOperationRepository.GetAll().Where(r => r.ResourceId == resourceId);
            var operations       = _operationRepository.GetAll().Where(r => r.ResourceId == resourceId);

            if (cyclicOperations.Any())
            {
                await _cyclicOperationRepository.DeleteBulk(cyclicOperations);
            }
            if (operations.Any())
            {
                await _operationRepository.DeleteBulk(operations);
            }

            await _repository.Delete(await _repository.Get(resourceId) ?? throw new ArgumentException("Resource not found"));
        }