public IHttpActionResult PutWorkTrip(long id, Dal.Invitation.Interfaces.WorkTrip workTrip) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != workTrip.Id) { return(BadRequest()); } db.Entry(workTrip).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!WorkTripExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetWorkTrip(long id) { Dal.Invitation.Interfaces.WorkTrip workTrip = db.WorkTrip.Find(id); if (workTrip == null) { return(NotFound()); } return(Ok(workTrip)); }
public IHttpActionResult PostWorkTrip(Dal.Invitation.Interfaces.WorkTrip workTrip) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.WorkTrip.Add(workTrip); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = workTrip.Id }, workTrip)); }
public IHttpActionResult DeleteWorkTrip(long id) { Dal.Invitation.Interfaces.WorkTrip workTrip = db.WorkTrip.Find(id); if (workTrip == null) { return(NotFound()); } db.WorkTrip.Remove(workTrip); db.SaveChanges(); return(Ok(workTrip)); }