public async Task CreateOrUpdatePriceLevel(CreatePriceLevelInput input) { if (input.Id != 0) { await UpdatePriceLevelAsync(input); } else { await CreatePriceLevelAsync(input); } }
public virtual async Task CreatePriceLevelAsync(CreatePriceLevelInput input) { var priceLevel = input.MapTo <PriceLevel>(); var val = _priceLevelRepository .GetAll().Where(p => p.PriceLevelCode == input.PriceLevelCode || p.PriceLevelName == input.PriceLevelName).FirstOrDefault(); if (val == null) { await _priceLevelRepository.InsertAsync(priceLevel); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in PriceLevel Code '" + input.PriceLevelCode + "' orPriceLevel Name '" + input.PriceLevelName + "'..."); } }
public virtual async Task UpdatePriceLevelAsync(CreatePriceLevelInput input) { var priceLevel = await _priceLevelRepository.GetAsync(input.Id); ObjectMapper.Map(input, priceLevel); var val = _priceLevelRepository .GetAll().Where(p => (p.PriceLevelCode == input.PriceLevelCode || p.PriceLevelName == input.PriceLevelName) && p.Id != input.Id).FirstOrDefault(); if (val == null) { await _priceLevelRepository.UpdateAsync(priceLevel); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in PriceLevel Code '" + input.PriceLevelCode + "' orPriceLevel Name '" + input.PriceLevelName + "'..."); } }