domBudg/back/Services/Reports/ReportOffsetFromPlanService.cs

33 lines
1.0 KiB
C#
Raw Normal View History

using Contracts.Mappers;
using Contracts.Repositories;
using Contracts.SearchModels;
using Contracts.Services;
using Contracts.ViewModels;
using Services.Support.Exceptions;
namespace Services.Reports;
public class ReportOffsetFromPlanService : IReportOffsetFromPlanService
{
private readonly ISpendingGroupRepo _spendingGroupRepo;
public ReportOffsetFromPlanService(ISpendingGroupRepo spendingGroupRepo)
{
_spendingGroupRepo = spendingGroupRepo;
}
public async Task<SpendingGroupViewModel> GetReportData(SpendingPlanSearch search)
{
var group = await _spendingGroupRepo.GetByPlan(search);
if (group == null)
{
throw new EntityNotFoundException("Не удалось найти группу по такому плану");
}
if (!group.ChangeRecords.Any())
{
throw new ReportDataNotFoundException("Данные об изменении баланса отсутствуют");
}
return group.ToView();
}
}