public IHttpActionResult PostMunitionRoles(MunitionRole munitionRoles) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MunitionRoles.Add(munitionRoles); try { db.SaveChanges(); } catch (DbUpdateException) { if (MunitionRolesExists(munitionRoles.id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApiPost", new { id = munitionRoles.id }, munitionRoles)); }
public IHttpActionResult PutMunitionRoles(int id, MunitionRole munitionRoles) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != munitionRoles.id) { return(BadRequest()); } db.Entry(munitionRoles).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MunitionRolesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult DeleteMunitionRoles(int id) { MunitionRole munitionRoles = db.MunitionRoles.Find(id); if (munitionRoles == null) { return(NotFound()); } db.MunitionRoles.Remove(munitionRoles); db.SaveChanges(); return(Ok(munitionRoles)); }
public IHttpActionResult GetMunitionRoles(int id) { MunitionRole munitionRoles = db.MunitionRoles.Find(id); if (munitionRoles == null) { return(NotFound()); } return(Ok(new DropDownDTO { id = munitionRoles.id.ToString(), description = munitionRoles.description })); }