public HttpResponseMessage Post([FromBody] APIModel.Employee employee) { if (!HelperFunctions.fBrowserIsMobile()) { if (employee == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong type is given for either of the field.")); } try { return(Request.CreateResponse(HttpStatusCode.OK, emp_service.Add(employee))); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "You only have read operation.Unauthorized access.")); } }
public HttpResponseMessage Put([FromBody] APIModel.Employee employee) { if (!HelperFunctions.fBrowserIsMobile()) { try { var updateEmp = emp_service.Update(employee); if (updateEmp == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Employee Not Found")); } return(Request.CreateResponse(HttpStatusCode.OK, updateEmp)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "You only have read operation.Unauthorized access.")); } }