Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public HostelController()
 {
     _hostelBL = new HostelBL();
 }