public CurrencyViewModel GetCurrency(string code) { var spec = new CurrencyByCodeSpec(code); var curr = currRepository.FindOne(spec); return(CurrencyViewModel.MapFromData(curr)); }
public void AddCurrency(CurrencyViewModel currency) { var existCurrSpec = new CurrencyByCodeSpec(currency.Code); var oldItem = currRepository.FindOne(existCurrSpec); if (oldItem != null) { throw new ValidationException($"Currency {currency.Code} already exist!"); } var curr = Currency.CreateCurrency(currency.Code, currency.ShortCode, currency.Symbol, currency.Name); try { unitOfWork.BeginTransaction(); currRepository.Add(curr); unitOfWork.Commit(); } catch (Exception) { unitOfWork.Rollback(); throw; } }