domBudg/back/Services/Reports/ReportOffsetFromPlanService.cs

33 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}
}