public IHttpActionResult PutHoursWork(int id, HoursWork hoursWork) { if (id != hoursWork.EmployeeId) { return(BadRequest()); } db.Entry(hoursWork).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HoursWorkExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostHoursWork(HoursWork hoursWork) { db.HoursWorks.Add(hoursWork); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = hoursWork.EmployeeId }, hoursWork)); }
public IHttpActionResult GetHoursWork(int id) { HoursWork hoursWork = db.HoursWorks.Find(id); if (hoursWork == null) { return(NotFound()); } return(Ok(hoursWork)); }
public IHttpActionResult DeleteHoursWork(int id) { HoursWork hoursWork = db.HoursWorks.Find(id); if (hoursWork == null) { return(NotFound()); } db.HoursWorks.Remove(hoursWork); db.SaveChanges(); return(Ok(hoursWork)); }