コード例 #1
0
        public static void Update(this Currency target, AbstractEntities.CurrencyUpdate source)
        {
            if (source == null || target == null)
            {
                return;
            }

            target.Code = source.Code;
        }
コード例 #2
0
        public AbstractEntities.Currency UpdateCurrency(AbstractEntities.CurrencyUpdate currencyUpdate)
        {
            if (currencyUpdate == null)
            {
                throw new ArgumentNullException("currencyUpdate");
            }

            lock (syncObject)
            {
                var record = context.Currencies.SingleOrDefault(c => c.Id == currencyUpdate.Id);
                if (record == null)
                {
                    throw new RecordDoesNotExistException($"Currency with ID {currencyUpdate.Id} does not exist.");
                }

                record.Update(currencyUpdate);

                context.SaveChanges();

                return(record.ToAbstract());
            }
        }