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

            target.Name = source.Name;
        }
コード例 #2
0
        public AbstractEntities.Category UpdateCategory(AbstractEntities.CategoryUpdate categoryUpdate)
        {
            if (categoryUpdate == null)
            {
                throw new ArgumentNullException("categoryUpdate");
            }

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

                record.Update(categoryUpdate);

                context.SaveChanges();

                return(record.ToAbstract());
            }
        }