public async Task <ActionResult <Attribute> > PostAttribute(Attribute attribute) { _context.Attributes.Add(attribute); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAttribute", new { id = attribute.AttributeId }, attribute)); }
public async Task <IActionResult> PutAttribute(int id, Attribute attribute) { if (id != attribute.AttributeId) { return(StatusCode(StatusCodes.Status500InternalServerError, new Response { Status = "Error", Message = "This attribute id does not exist!" })); } _context.Entry(attribute).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AttributeExists(id)) { return(StatusCode(StatusCodes.Status500InternalServerError, new Response { Status = "Error", Message = "This attribute id does not exist!" })); } else { throw; } } return(NoContent()); }