Ejemplo n.º 1
0
        public async Task <IActionResult> PatchAsync(int id, Delta <T> value, CancellationToken cancellationToken)
        {
            var current = await _records.SingleOrDefaultAsync(r => r.Id == id, cancellationToken);

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

            value.ApplyPatch(current);

            TryValidateModel(current);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _context.SaveChangesAsync(cancellationToken);

            return(Ok(current));
        }