// GET api/EmployeeBenefit/5 public EBenefit GetEmployeeBenefit(int id) { EBenefit employeebenefit = db.EmployeeBenefits.Find(id); if (employeebenefit == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(employeebenefit); }
// POST api/EmployeeBenefit public HttpResponseMessage PostEmployeeBenefit(EBenefit employeebenefit) { if (ModelState.IsValid) { db.EmployeeBenefits.Add(employeebenefit); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, employeebenefit); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
// DELETE api/EmployeeBenefit/5 public HttpResponseMessage DeleteEmployeeBenefit(int id) { EBenefit employeebenefit = db.EmployeeBenefits.Find(id); if (employeebenefit == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } db.EmployeeBenefits.Remove(employeebenefit); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, employeebenefit)); }
// PUT api/EmployeeBenefit/5 public HttpResponseMessage PutEmployeeBenefit(int id, EBenefit employeebenefit) { if (ModelState.IsValid && id == employeebenefit.EmployeeBenefitId) { db.Entry(employeebenefit).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }