示例#1
0
 public async Task CreateOrUpdatePriceLevel(CreatePriceLevelInput input)
 {
     if (input.Id != 0)
     {
         await UpdatePriceLevelAsync(input);
     }
     else
     {
         await CreatePriceLevelAsync(input);
     }
 }
示例#2
0
        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 + "'...");
            }
        }
示例#3
0
        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 + "'...");
            }
        }