public IHttpActionResult PostSpecialIntrest(SpecialIntrest specialIntrest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SpecialIntrests.Add(specialIntrest); try { db.SaveChanges(); } catch (DbUpdateException) { if (SpecialIntrestExists(specialIntrest.IntrestCode)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = specialIntrest.IntrestCode }, specialIntrest)); }
public IHttpActionResult PutSpecialIntrest(string id, SpecialIntrest specialIntrest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != specialIntrest.IntrestCode) { return(BadRequest()); } db.Entry(specialIntrest).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SpecialIntrestExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetSpecialIntrest(string id) { SpecialIntrest specialIntrest = db.SpecialIntrests.Find(id); if (specialIntrest == null) { return(NotFound()); } return(Ok(specialIntrest)); }
public IHttpActionResult DeleteSpecialIntrest(string id) { SpecialIntrest specialIntrest = db.SpecialIntrests.Find(id); if (specialIntrest == null) { return(NotFound()); } db.SpecialIntrests.Remove(specialIntrest); db.SaveChanges(); return(Ok(specialIntrest)); }