public IHttpActionResult PutMRCorporate(int id, MRCorporate mRCorporate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mRCorporate.ID) { return(BadRequest()); } db.Entry(mRCorporate).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MRCorporateExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetMRCorporate(int id) { MRCorporate mRCorporate = db.MRCorporates.Find(id); if (mRCorporate == null) { return(NotFound()); } return(Ok(mRCorporate)); }
public IHttpActionResult DeleteMRCorporate(int id) { MRCorporate mRCorporate = db.MRCorporates.Find(id); if (mRCorporate == null) { return(NotFound()); } db.MRCorporates.Remove(mRCorporate); db.SaveChanges(); return(Ok(mRCorporate)); }
public IHttpActionResult PostMRCorporate(MRCorporate mRCorporate) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} var errors = ModelState.Values.SelectMany(v => v.Errors); db.MRCorporates.Add(mRCorporate); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = mRCorporate.ID }, mRCorporate)); }