예제 #1
0
        public dynamic GetBookings(string timeframe)
        {
            var username = new TApiAuth().GetLoggedInUsername(Request);

            if (string.IsNullOrEmpty(username))
            {
                return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
            }


            var bookings = _bookingManager.GetBookingDoneByUser(username);
            var compare  = timeframe == "upcoming" ? 1 : -1;
            var filter   = bookings.Where(x => x.starttime.CompareTo(DateTime.UtcNow) == compare);
            var result   = filter.Select(x => { return(new { Id = x.Id, isCancelled = x.isCancelled, Room = new { Id = x.RoomId, image = "Content\\img\\room.jpg", Name = _roomManager.GetRoomById(x.RoomId).RoomName }, Date = x.starttime.ToShortDateString(), StartTime = x.starttime.ToShortTimeString(), EndTime = x.endtime.ToShortTimeString(), BookedOn = x.createdOn }); });

            return(result);
        }