public async Task CreateOrUpdatePriceLevel(PriceLevelCreate input) { if (input.Id != 0) { await UpdatePriceLevel(input); } else { await CreatePriceLevel(input); } }
public async Task CreatePriceLevel(PriceLevelCreate input) { using (_unitOfWorkManager.Current.SetTenantId(_session.TenantId)) { input.TenantId = (int)_session.TenantId; var quey = input.MapTo <PriceLevel>(); var val = _priceLevelRepository .GetAll().Where(p => p.PriceLevelCode == input.PriceLevelCode || p.PriceLevelName == input.PriceLevelName).FirstOrDefault(); if (val == null) { await _priceLevelRepository.InsertAsync(quey); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in PriceLevelCode '" + input.PriceLevelCode + "' or PriceLevelName '" + input.PriceLevelName + "'..."); } } }