public async Task <MunicipalityTaxScheduleDto> AddNewMunicipalityTax(MunicipalityTaxScheduleDto municipalityTaxScheduleDto) { bool isValid = MunicipalityTaxScheduleValidator.IsValid(municipalityTaxScheduleDto); if (!isValid) { throw new ValidationException(); } MunicipalityTaxSchedules taxSchedule = MunicipalityTaxScheduleMapper.ToEntity(municipalityTaxScheduleDto); taxSchedule.CreatedOn = DateTime.Now; await _municipalityTaxScheduleRepository.AddTaxSchedule(taxSchedule); return(MunicipalityTaxScheduleMapper.ToDto(taxSchedule)); }
public async Task <int> BulkAddMunicipalityTax(IEnumerable <MunicipalityTaxScheduleDto> municipalityTaxScheduleDtos) { bool isValid = municipalityTaxScheduleDtos.All(_ => MunicipalityTaxScheduleValidator.IsValid(_)); if (!isValid) { throw new ValidationException(); } IEnumerable <MunicipalityTaxSchedules> taxSchedules = municipalityTaxScheduleDtos.Select(_ => { var entity = MunicipalityTaxScheduleMapper.ToEntity(_); entity.CreatedOn = DateTime.Now; return(entity); }); return(await _municipalityTaxScheduleRepository.BulkInsertTaxSchedule(taxSchedules)); }