Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Patch([FromODataUri] int TransactionTypeID, Delta <TransactionType> patch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var item = await _service.FindAsync(TransactionTypeID);

            if (item == null)
            {
                return(NotFound());
            }

            patch.Patch(item);
            item.ObjectState = ObjectState.Modified;

            try
            {
                await _unitOfWorkAsync.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(TransactionTypeID))
                {
                    return(NotFound());
                }
                throw;
            }

            return(Updated(item));
        }