示例#1
0
        private static void SaveChangesfromBooking(string userName, BookMeetingRoomForm entity, out string nameRoom)
        {
            var db       = new Model.EntityModelContainer();
            var typeRoom = false;

            nameRoom = string.Empty;

            if (entity.TypeRoom.Value.ToString() == With_Projector)
            {
                typeRoom = true;
            }

            var listNomRoom = db.RoomSet.Where(b => b.Projector == typeRoom && b.Size >= entity.Attendant);

            db.Bookings.Add(new Model.Booking
            {
                EmplyeeId = userName,
                StartDate = entity.StartDate,
                StartTime = entity.StartTime,
                EndTime   = entity.EndTime,
                Attendant = entity.Attendant,
                Room      = listNomRoom.First(),
                IsCancel  = false,
            });

            nameRoom = listNomRoom.First().NameRoom.ToString();

            db.SaveChanges();
        }
示例#2
0
        private static void ShowBookings(IDialogContext context, ViewMeetingRoomForm entity, out bool result)
        {
            var db = new Model.EntityModelContainer();

            result = false;
            var user = context.Activity.From.Name;

            IQueryable <Model.Booking> contactQuery = null;

            // Iterate through the results of the parameterized query.
            foreach (var list in contactQuery)
            {
                var cont     = 0;
                var nameRoom = db.RoomSet.FirstOrDefault(b => b.Id == list.Room.Id);


                //$"Resesrvation {cont.ToString()}";

                context.PostAsync("Reservation " + cont.ToString() + "." + "Meeting Room: " + nameRoom +
                                  " Start Date: " + list.StartDate.ToShortDateString() +
                                  " Start Time: " + list.StartTime.ToShortTimeString() +
                                  " End Time: " + list.EndTime.ToShortTimeString() +
                                  " Attendant: " + list.Attendant.ToString() +
                                  "/n/r");
            }
        }
        private static async Task PostMeetingRoomCarousel(IDialogContext context, string typeAction)
        {
            var db         = new Model.EntityModelContainer();
            var user       = context.Activity.From.Name;
            var reply      = context.MakeMessage();
            var TypeAction = string.Empty;


            if (typeAction == "View")
            {
                TypeAction = ActionTypes.ShowImage;
            }
            else
            {
                TypeAction = ActionTypes.PostBack;
            }


            reply.AttachmentLayout = "carousel";

            var contactQuery = from Bookings in db.Bookings
                               where Bookings.EmplyeeId == user && Bookings.IsCancel == false
                               select Bookings;

            // Iterate through the results of the parameterized query.
            foreach (var list in contactQuery)
            {
                var heroCard = new HeroCard();

                heroCard.Buttons = new List <CardAction>
                {
                    new CardAction
                    {
                        // Type, title and value are required!
                        Type  = TypeAction,
                        Title = $"{list.Room.NameRoom} - {list.StartDate.ToShortDateString()} - {list.StartTime.ToShortTimeString()}",
                        Value = $"{list.Id}",
                    }
                };
                heroCard.Title  = string.Empty;
                heroCard.Images = new List <CardImage>
                {
                    new CardImage
                    {
                        Url = GetImageOfMeetingRoom(list.Room.NameRoom)
                    }
                };

                reply.Attachments.Add(heroCard.ToAttachment());
            }

            await context.PostAsync(reply);
        }
        private async Task SaveChangesfromCancelBooking(IDialogContext context, IAwaitable <string> result)
        {
            using (var db = new Model.EntityModelContainer())
            {
                var id = 0;

                id = int.Parse(result.GetAwaiter().GetResult());

                var itemToRemove = db.Bookings.SingleOrDefault(b => b.Id == id);

                itemToRemove.IsCancel = true;

                db.SaveChanges();
            }

            await context.PostAsync("Great....Cancelled Reservation.");
        }
        private bool CheckBooksforUser(IDialogContext context)
        {
            var db = new Model.EntityModelContainer();
            var id = context.Activity.From.Name;

            var message = string.Empty;

            var item = db.Bookings.FirstOrDefault(b => b.EmplyeeId == id && b.IsCancel == false);

            if (item == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }