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()); } }
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()); } }
public static Reservation GetReservationById(long id) { using (HotelTelegramBotContext db = new HotelTelegramBotContext()) { return(db.Reservations .Where(r => r.Id == id) .FirstOrDefault()); } }
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(); } }
public static HotelRoomType GetHotelRoomTypeById(long hotelRoomTypeId) { using (HotelTelegramBotContext db = new HotelTelegramBotContext()) { return(db.HotelRoomTypes .Where(t => t.Id == hotelRoomTypeId) .FirstOrDefault()); } }
public static List <Reservation> GetReservationByChatId(long chatId) { using (HotelTelegramBotContext db = new HotelTelegramBotContext()) { return(db.Reservations .Where(r => r.IdUserChat == chatId) .ToList()); } }
public static List <HotelRoomReservedDate> GetHotelRoomReservedDatesByReservationId(long reservationId) { using (HotelTelegramBotContext db = new HotelTelegramBotContext()) { return(db.HotelRoomReservedDate .Where(date => date.ReservationId == reservationId) .ToList()); } }
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()); } }
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()); } }
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()); } }
public static async Task <Reservation> AddReservationAsync(Reservation reservation) { using (HotelTelegramBotContext db = new HotelTelegramBotContext()) { Reservation r = db.Reservations.Add(reservation); await db.SaveChangesAsync(); return(r); } }
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()); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }