Esempio n. 1
0
 public async Task CreateOrUpdateCurrency(CreateCurrencyInput input)
 {
     if (input.Id != 0)
     {
         await UpdateCurrencyAsync(input);
     }
     else
     {
         await CreateCurrencyAsync(input);
     }
 }
Esempio n. 2
0
        public virtual async Task UpdateCurrencyAsync(CreateCurrencyInput input)
        {
            var Currency = input.MapTo <Currency>();
            var val      = _CurrencyRepository
                           .GetAll().Where(p => (p.Code == input.Code || p.Name == input.Name) && p.Id != input.Id).FirstOrDefault();

            if (val == null)
            {
                await _CurrencyRepository.UpdateAsync(Currency);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Currency Name '" + input.Name + "' or Currency Code '" + input.Code + "'...");
            }
        }
Esempio n. 3
0
        public virtual async Task CreateCurrencyAsync(CreateCurrencyInput input)
        {
            var      Currency      = input.MapTo <Currency>();
            DateTime myUtcDateTime = DateTime.Now;

            try
            {
                var val = _CurrencyRepository
                          .GetAll().Where(p => p.Code == input.Code || p.Name == input.Name).FirstOrDefault();
                if (val == null)
                {
                    await _CurrencyRepository.InsertAsync(Currency);
                }
                else
                {
                    throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Currency Name '" + input.Name + "' or Currency Code '" + input.Code + "'...");
                }
            }
            catch (Exception obj)
            {
                string dd = obj.Message.ToString();
            }
        }