public HttpResponseMessage GetUserByID(int id) { objHostelBL = new HostelBL(); int vendorid = id; HttpResponseMessage response; try { var detailsResponse = objHostelBL.GetUserById(vendorid); if (detailsResponse != null) { response = Request.CreateResponse <List <UserDetails> >(HttpStatusCode.OK, detailsResponse); } else { response = new HttpResponseMessage(HttpStatusCode.NotFound); } } catch (Exception ex) { response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); } return(response); }
public HttpResponseMessage SaveOrUpdateUser([FromBody] UserDetails userDetails) { objHostelBL = new HostelBL(); HttpResponseMessage response; try { var detailsResponse = objHostelBL.SaveOrUpdateUser(userDetails); if (detailsResponse != null) { response = Request.CreateResponse <int>(HttpStatusCode.OK, detailsResponse); } else { response = new HttpResponseMessage(HttpStatusCode.NotFound); } } catch (Exception ex) { response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); } return(response); }
public HostelController() { _hostelBL = new HostelBL(); }