public async Task CreateOrUpdateValidity(CreateValidityInput input) { if (input.Id != 0) { await UpdateValidity(input); } else { await CreateValidity(input); } }
public async Task CreateValidity(CreateValidityInput input) { using (_unitOfWorkManager.Current.SetTenantId(_session.TenantId)) { input.TenantId = (int)_session.TenantId; var Validity = input.MapTo <Validity>(); var val = _ValidityRepository .GetAll().Where(p => p.ValidityCode == input.ValidityCode || p.ValidityName == input.ValidityName).FirstOrDefault(); if (val == null) { await _ValidityRepository.InsertAsync(Validity); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in ValidityName '" + input.ValidityName + "' or ValidityCode '" + input.ValidityCode + "'..."); } } }