Ejemplo n.º 1
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();
     }
 }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
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();
            }
        }
Ejemplo n.º 6
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();
            }
        }
Ejemplo n.º 7
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();
            }
        }
Ejemplo n.º 8
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();
            }
        }