public async Task <IActionResult> PutEntity(int id, TemplateEntity entity) { if (id != entity.Id) { return(BadRequest()); } try { _context.Update(entity); _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { System.Diagnostics.Debug.WriteLine(e.Message); if (!EntityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <TemplateEntity> > Put(int id, TemplateEntity entity) { // Add your code below, this is an example for basic implementation if (!ModelState.IsValid) { return(BadRequest()); } try { _context.Update(entity); _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); return(StatusCode(401)); } return(StatusCode(201)); }