public HttpResponseMessage Put(int id, [FromBody] Employee EmpObj)
 {
     try
     {
         using (dbsampleEntities entityObj = new dbsampleEntities())
         {
             Employee Emp = entityObj.Employees.FirstOrDefault(emp => emp.EmpID == id);
             if (EmpObj == null)
             {
                 return(Request.CreateResponse(HttpStatusCode.NotFound, "Employee with the id=" + id + " not found"));
             }
             else
             {
                 Emp.EmpName     = EmpObj.EmpName;
                 Emp.EmpSalary   = EmpObj.EmpSalary;
                 Emp.EmpLocation = EmpObj.EmpLocation;
                 entityObj.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, "Updated"));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }
 public HttpResponseMessage Post([FromBody] Employee EmpObj)
 {
     try
     {
         using (dbsampleEntities entityObj = new dbsampleEntities())
         {
             entityObj.Employees.Add(EmpObj);
             entityObj.SaveChanges();
             var message = Request.CreateResponse(HttpStatusCode.Created, EmpObj);
             message.Headers.Location = new Uri(Request.RequestUri + EmpObj.EmpID.ToString());
             return(message);
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         using (dbsampleEntities entityObj = new dbsampleEntities())
         {
             Employee EmpObj = entityObj.Employees.FirstOrDefault(emp => emp.EmpID == id);
             if (EmpObj == null)
             {
                 return(Request.CreateResponse(HttpStatusCode.NotFound, "Employee with the id=" + id + " not found"));
             }
             else
             {
                 entityObj.Employees.Remove(EmpObj);
                 entityObj.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, "Deleted"));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }