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

            var item = await _service.FindAsync(StateProvinceID);

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

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

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

            return(Updated(item));
        }