Ejemplo n.º 1
0
        public List <RoomModel> GetRooms(string city, string pincode, int?price, int?category)
        {
            List <RoomModel>  destination = new List <RoomModel>();
            IQueryable <Room> query       = RoomRepository.GetQueryable().OrderBy(x => x.Price);

            if (city != null)
            {
                query = query.Where(x => x.Hotel.City == city);
            }
            if (pincode != null)
            {
                query = query.Where(x => x.Hotel.PinCode == pincode);
            }
            if (price != null)
            {
                query = query.Where(x => x.Price == price);
            }
            if (category != null)
            {
                query = query.Where(x => x.Category == category);
            }
            foreach (Room room in query.ToList())
            {
                destination.Add(ModelMapperService.Map <Room, RoomModel>(room));
            }
            return(destination);
        }
Ejemplo n.º 2
0
        public List <RoomModel> GetRooms()
        {
            List <Room>      source      = RoomRepository.GetQueryable().OrderBy(x => x.Price).ToList();
            List <RoomModel> destination = new List <RoomModel>();

            foreach (Room room in source)
            {
                destination.Add(ModelMapperService.Map <Room, RoomModel>(room));
            }
            return(destination);
        }
        public HotelModel GetHotelById(int id)
        {
            var cachedData = this._redisManager.GetFromHash <HotelModel>(id.ToString());

            if (cachedData != null && cachedData.HotelId > 0)
            {
                return(cachedData);
            }
            else
            {
                var data = ModelMapperService.Map <Hotel, HotelModel>(HotelRepository.GetHotelById(id));
                this._redisManager.StoreAsHasMap <HotelModel>(id.ToString(), data);
                return(data);
            }
        }
        public List <BookingModel> GetBookings()
        {
            var cachedData = this._redisManager.GetList <BookingModel>().ToList();

            if (cachedData == null || !cachedData.Any())
            {
                List <Booking>      source      = BookingRepository.GetQueryable().OrderBy(x => x.BookingDate).ToList();
                List <BookingModel> destination = new List <BookingModel>();
                foreach (Booking booking in source)
                {
                    destination.Add(ModelMapperService.Map <Booking, BookingModel>(booking));
                }
                this._redisManager.SetList <BookingModel>(destination);
                return(destination);
            }
            else
            {
                return(cachedData);
            }
        }
        public List <HotelModel> GetHotels()
        {
            var cachedData = this._redisManager.Get <List <HotelModel> >(CACHE_KEY_PREFIX + 0);

            if (cachedData == null || !cachedData.Any())
            {
                List <Hotel>      source      = HotelRepository.GetQueryable().OrderBy(x => x.Name).ToList();
                List <HotelModel> destination = new List <HotelModel>();
                foreach (Hotel hotel in source)
                {
                    destination.Add(ModelMapperService.Map <Hotel, HotelModel>(hotel));
                }
                this._redisManager.AddRange <HotelModel>("Hotels", destination);
                this._redisManager.StoreAsHasMap <HotelModel>(destination, "HotelId");
                this._redisManager.Set <List <HotelModel> >(CACHE_KEY_PREFIX + 0, destination);
                return(destination);
            }
            else
            {
                return(cachedData);
            }
        }
        public List <HotelModel> GetHotels(string name, string city, string pincode)
        {
            List <HotelModel>  destination = new List <HotelModel>();
            IQueryable <Hotel> query       = HotelRepository.GetQueryable().OrderBy(x => x.Name);

            if (name != null)
            {
                query = query.Where(x => x.Name.Contains(name) || x.Name.StartsWith(name) || x.Name.EndsWith(name));
            }
            if (city != null)
            {
                query = query.Where(x => x.City == city);
            }
            if (pincode != null)
            {
                query = query.Where(x => x.PinCode == pincode);
            }
            foreach (Hotel hotel in query.ToList())
            {
                destination.Add(ModelMapperService.Map <Hotel, HotelModel>(hotel));
            }
            return(destination);
        }
        public List <BookingModel> GetBookings(Nullable <DateTime> date, int?roomId, int?hotelId)
        {
            List <BookingModel>  destination = new List <BookingModel>();
            IQueryable <Booking> query       = BookingRepository.GetQueryable().OrderBy(x => x.BookingDate);

            if (roomId != null)
            {
                query = query.Where(x => x.RoomId == roomId);
            }
            if (hotelId != null)
            {
                query = query.Where(x => x.Room.HotelId == hotelId);
            }
            if (date != null)
            {
                query = query.Where(x => x.BookingDate == date);
            }
            foreach (Booking booking in query.ToList())
            {
                destination.Add(ModelMapperService.Map <Booking, BookingModel>(booking));
            }
            return(destination);
        }
 public bool UpdateHotel(HotelModel hotel)
 {
     return(HotelRepository.UpdateHotel(ModelMapperService.Map <HotelModel, Hotel>(hotel)));
 }
Ejemplo n.º 9
0
 public bool UpdateRoom(RoomModel room)
 {
     return(RoomRepository.UpdateRoom(ModelMapperService.Map <RoomModel, Room>(room)));
 }
Ejemplo n.º 10
0
 public RoomModel GetRoomById(int id)
 {
     return(ModelMapperService.Map <Room, RoomModel>(RoomRepository.GetRoomById(id)));
 }
 public bool UpdateBooking(BookingModel booking)
 {
     return(BookingRepository.UpdateBooking(ModelMapperService.Map <BookingModel, Booking>(booking)));
 }
 public BookingModel GetBooking(int id)
 {
     return(ModelMapperService.Map <Booking, BookingModel>(BookingRepository.GetBooking(id)));
 }