Esempio n. 1
0
 public static List <HotelRoomType> GetHotelRoomTypes()
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.HotelRoomTypes
                .ToList());
     }
 }
 public static HotelRoom GetHotelRoomById(long id)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.HotelRooms
                .Where(r => r.Id == id)
                .FirstOrDefault());
     }
 }
 public static List <HotelRoomTypeImage> GetHotelRoomTypeImages(long hotelRoomTypeId)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.HotelRoomTypeImages
                .Where(i => i.HotelRoomTypeId == hotelRoomTypeId)
                .ToList());
     }
 }
Esempio n. 4
0
 public static UserChat GetUserChatByIdChat(long idChat)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.UserChats
                .Where(u => u.IdChat == idChat)
                .FirstOrDefault());
     }
 }
 public static List <HotelRoom> GetAviableHotelRooms(List <long> reservedHotelRoomId)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.HotelRooms
                .Where(r => !reservedHotelRoomId.Contains(r.Id))
                .ToList());
     }
 }
Esempio n. 6
0
 public static Reservation GetReservationById(long id)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.Reservations
                .Where(r => r.Id == id)
                .FirstOrDefault());
     }
 }
Esempio n. 7
0
 public static async Task AddUserChatAsync(long id, long idChat, string chatPosition)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         UserChat user = new UserChat(0, idChat, chatPosition);
         db.UserChats.Add(user);
         await db.SaveChangesAsync();
     }
 }
Esempio n. 8
0
 public static HotelRoomType GetHotelRoomTypeById(long hotelRoomTypeId)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.HotelRoomTypes
                .Where(t => t.Id == hotelRoomTypeId)
                .FirstOrDefault());
     }
 }
Esempio n. 9
0
 public static List <Reservation> GetReservationByChatId(long chatId)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.Reservations
                .Where(r => r.IdUserChat == chatId)
                .ToList());
     }
 }
Esempio n. 10
0
 public static List <HotelRoomReservedDate> GetHotelRoomReservedDatesByReservationId(long reservationId)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.HotelRoomReservedDate
                .Where(date => date.ReservationId == reservationId)
                .ToList());
     }
 }
Esempio n. 11
0
 public static TempInformation GetTempInformation(long chatId, string property)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.TempInformation
                .Where(t => t.IdUserChat == chatId)
                .Where(t => t.Property == property)
                .First());
     }
 }
Esempio n. 12
0
 public static List <HotelRoomType> GetHotelRoomTypes(int numberOfAdults, int numberOfChildren)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.HotelRoomTypes
                .Where(t => t.MaxNumberOfAdults >= numberOfAdults)
                .Where(t => t.MaxNumberOfChildren >= numberOfChildren)
                .ToList());
     }
 }
Esempio n. 13
0
 public static List <long> GetReservationIds(List <string> dates)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.HotelRoomReservedDate
                .Where(d => dates.Contains(d.ReservedDate))
                .Select(d => d.ReservationId)
                .ToList());
     }
 }
Esempio n. 14
0
        public static async Task <Reservation> AddReservationAsync(Reservation reservation)
        {
            using (HotelTelegramBotContext db = new HotelTelegramBotContext())
            {
                Reservation r = db.Reservations.Add(reservation);
                await db.SaveChangesAsync();

                return(r);
            }
        }
Esempio n. 15
0
 public static List <long> GetReservedHotelRoomIds(List <long> reservationIds)
 {
     using (HotelTelegramBotContext db = new HotelTelegramBotContext())
     {
         return(db.Reservations
                .Where(r => reservationIds.Contains(r.Id))
                .Select(r => r.HotelRoomId)
                .ToList());
     }
 }
Esempio n. 16
0
        public static async Task UpdateChatPositionAsync(long idChat, string position)
        {
            using (HotelTelegramBotContext db = new HotelTelegramBotContext())
            {
                db.UserChats
                .Where(u => u.IdChat == idChat)
                .FirstOrDefault().ChatPosition = position;

                await db.SaveChangesAsync();
            }
        }
Esempio n. 17
0
        public static async Task DeleteReservationByIdAsync(long id)
        {
            Reservation r = GetReservationById(id);

            using (HotelTelegramBotContext db = new HotelTelegramBotContext())
            {
                db.Reservations.Attach(r);
                db.Reservations.Remove(r);

                await db.SaveChangesAsync();
            }
        }
Esempio n. 18
0
        public static async Task RemoveRangeTempInformationByChatIdAsync(long chatId)
        {
            using (HotelTelegramBotContext db = new HotelTelegramBotContext())
            {
                var values = db.TempInformation
                             .Where(t => t.IdUserChat == chatId);

                db.TempInformation
                .RemoveRange(values);

                await db.SaveChangesAsync();
            }
        }
Esempio n. 19
0
        internal static async Task DeleteHotelRoomReservedDateDatesAsync(List <HotelRoomReservedDate> dates)
        {
            using (HotelTelegramBotContext db = new HotelTelegramBotContext())
            {
                foreach (HotelRoomReservedDate date in dates)
                {
                    db.HotelRoomReservedDate.Attach(date);
                    db.HotelRoomReservedDate.Remove(date);
                }

                await db.SaveChangesAsync();
            }
        }
Esempio n. 20
0
        public static async Task AddTempInformationAsync(long chatId, string property, string value)
        {
            using (HotelTelegramBotContext db = new HotelTelegramBotContext())
            {
                var obj = new TempInformation()
                {
                    IdUserChat = chatId,
                    Property   = property,
                    Value      = value
                };
                db.TempInformation.Add(obj);

                await db.SaveChangesAsync();
            }
        }
Esempio n. 21
0
        public static async Task AddHotelRoomReservedDatesAsync(long reservationId, List <string> dates)
        {
            using (HotelTelegramBotContext db = new HotelTelegramBotContext())
            {
                foreach (string date in dates)
                {
                    var reservedDate = new HotelRoomReservedDate
                    {
                        ReservationId = reservationId,
                        ReservedDate  = date
                    };

                    db.HotelRoomReservedDate.Add(reservedDate);
                }
                await db.SaveChangesAsync();
            }
        }