public async Task CreateOrUpdateCurrency(CreateCurrencyInput input) { if (input.Id != 0) { await UpdateCurrencyAsync(input); } else { await CreateCurrencyAsync(input); } }
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 + "'..."); } }
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(); } }