public async Task <IActionResult> PostAttribute([FromBody] Attribute attribute) { if (!ModelState.IsValid) { return(HttpResponseHelper.BadRequest(ModelState)); } _context.Attributes.Add(attribute); var error = await SaveChangesAsync(); if (error != null) { return(error); } return(CreatedAtRoute("GetAttribute", new { id = attribute.Id }, attribute)); }
public async Task <IActionResult> PutAttribute([FromRoute] Guid id, [FromBody] Attribute attribute) { if (!ModelState.IsValid) { return(HttpResponseHelper.BadRequest(ModelState)); } if (id != attribute.Id) { return(HttpResponseHelper.BadRequest("Invalid Attribute Id.")); } _context.Entry(attribute).State = EntityState.Modified; var error = await SaveChangesAsync(); if (error != null) { return(error); } return(CreatedAtRoute("GetAttribute", new { id = attribute.Id }, attribute)); }