//add new record
 public HttpResponseMessage Post([FromBody] LEAVEALLOCATION leaveallocation)
 {
     try
     {
         using (LeaveAllocationEntities entity = new LeaveAllocationEntities())
         {
             entity.LEAVEALLOCATION.Add(leaveallocation);
             entity.SaveChanges();
             HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, leaveallocation);
             message.Headers.Location = new Uri(Request.RequestUri + leaveallocation.JobTitleId.ToString());
             return(message);
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
 //delete data
 public HttpResponseMessage Delete(int jobtitleid, int leavetypeid)
 {
     try
     {
         using (LeaveAllocationEntities entity = new LeaveAllocationEntities())
         {
             var record = entity.LEAVEALLOCATION.Find(jobtitleid, leavetypeid);
             if (record == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "record doesnt exist"));
             }
             else
             {
                 entity.LEAVEALLOCATION.Remove(record);
                 entity.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
 // update allocated leave for specific jobtitle and leavetype
 public HttpResponseMessage put(int jobtitleid, int leavetypeid, [FromBody] LEAVEALLOCATION updatedleave)
 {
     try
     {
         using (LeaveAllocationEntities e = new LeaveAllocationEntities())
         {
             var entity = e.LEAVEALLOCATION.Find(jobtitleid, leavetypeid);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "record doesn't exist"));
             }
             else
             {
                 entity.NumberOfLeave = updatedleave.NumberOfLeave;
                 e.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }