public HttpResponseMessage CreateRoom(RoomInfo room) { try { room.CreatedByDate = DateTime.Now; room.CreatedByUserId = UserInfo.UserID; room.LastUpdatedByDate = DateTime.Now; room.LastUpdatedByUserId = UserInfo.UserID; RoomDataAccess.CreateItem(room); var savedRoom = RoomDataAccess.GetItems(room.CodeCampId).OrderByDescending(r => r.CreatedByDate).FirstOrDefault(); var response = new ServiceResponse <RoomInfo> { Content = savedRoom }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage GetRooms(int codeCampId) { try { var rooms = RoomDataAccess.GetItems(codeCampId); var response = new ServiceResponse <List <RoomInfo> > { Content = rooms.ToList() }; if (rooms == null) { ServiceResponseHelper <List <RoomInfo> > .AddNoneFoundError("rooms", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }