public async Task <IHttpActionResult> PutGroupACategory(int id, GroupACategory groupACategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != groupACategory.Id) { return(BadRequest()); } db.Entry(groupACategory).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupACategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetGroupACategory(int id) { GroupACategory groupACategory = await db.GroupACategories.FindAsync(id); if (groupACategory == null) { return(NotFound()); } return(Ok(groupACategory)); }
public async Task <IHttpActionResult> PostGroupACategory(GroupACategory groupACategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.GroupACategories.Add(groupACategory); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = groupACategory.Id }, groupACategory)); }
public async Task <IHttpActionResult> DeleteGroupACategory(int id) { GroupACategory groupACategory = await db.GroupACategories.FindAsync(id); if (groupACategory == null) { return(NotFound()); } db.GroupACategories.Remove(groupACategory); await db.SaveChangesAsync(); return(Ok(groupACategory)); }