private static void ValidateAbonement(AbonementDto item) { if (item is null) { throw new BusinessLogicException(StringRes.NullEntityMsg, new ArgumentNullException(nameof(item))); } if (string.IsNullOrEmpty(item.Name)) { throw new ValidationException(Resources.StringRes.EmptyNameMsg, nameof(item.Name)); } if (item.Attendances < Constants.AbonementAttendancesMinimum) { throw new ValidationException(Resources.StringRes.NegativeAttendancesMsg, nameof(item.Attendances)); } if (item.Coefficient > Constants.CoefficientMaximum || item.Coefficient < Constants.CoefficientMinimum) { throw new ValidationException(StringRes.CoefficientBoundsMsg, fieldName: nameof(item.Coefficient)); } }
public async Task UpdateAbonementAsync(AbonementDto item) { ValidateAbonement(item); await _abonementEntityService.UpdateAsync(_mapper.Map <Abonement>(item)); }
// ABONEMENT public async Task <int> CreateAbonementAsync(AbonementDto item) { ValidateAbonement(item); return(await _abonementEntityService.CreateAsync(_mapper.Map <Abonement>(item))); }