Beispiel #1
0
        private void SeatSelection(IWebElement canvasElement, int i, int j, string classes)
        {
            SeatDetail seatDetail = ConstructSeat(classes, i, j);

            if (dictSeatSelection.ContainsKey(seatDetail.Color))
            {
                //add seat selection for an already existing seat category
                List <SeatDetail> existingSeats = dictSeatSelection[seatDetail.Color];
                int tmpCount = randomPaxPerCategory[seatDetail.Color];

                //check with the max pax value
                if (existingSeats.Contains(seatDetail) == false && tmpCount > existingSeats.Count)
                {
                    existingSeats.Add(seatDetail);
                    BookSeat(canvasElement, seatDetail);
                }
            }
            else
            {
                //add the color with a random generated pax count for that seat category
                Random randomPaxCount = new Random();
                int    paxCount       = randomPaxCount.Next(1, 3);
                randomPaxPerCategory.Add(seatDetail.Color, paxCount);

                //add a fresh category with a new list of seats
                List <SeatDetail> newSeats = new List <SeatDetail>();
                newSeats.Add(seatDetail);
                dictSeatSelection.Add(seatDetail.Color, newSeats);
                BookSeat(canvasElement, seatDetail);
            }
        }
        //快速就坐
        public ActionResult OrderSeat(int id, int other)
        {
            int userId = Convert.ToInt32(Session["UserId"]);

            SeatDetail IsExist = Entity.SeatDetail.FirstOrDefault(a => a.UserId == userId && a.State != "离座");

            if (IsExist != null)
            {
                return(RedirectDialogToAction("已有未离座的记录,请注销其他记录,再进行操作!", true));
            }

            DateTime now  = DateTime.Now;
            Seat     seat = Entity.Seat.FirstOrDefault(a => a.Id == id && a.RoomId == other);

            seat.State = "使用中";
            Entity.Entry(seat).State = EntityState.Modified;

            SeatDetail seatDetail = new SeatDetail();

            seatDetail.SeatId    = id;
            seatDetail.UserId    = userId;
            seatDetail.StartTime = now;
            seatDetail.State     = "正常";
            Entity.SeatDetail.Add(seatDetail);

            string msg = string.Format("就坐成功!{0}自习室{1}号座位, 开始时间{2}。", seat.StuRoom.Name, seat.Id, seatDetail.StartTime);

            return(RedirectDialogToAction("OrderHistory", "UserSeat", msg, Entity.SaveChanges()));
        }
Beispiel #3
0
        private void BookSeat(IWebElement canvasElement, SeatDetail seatDetail)
        {
            Actions actionClick = new Actions(driver);

            actionClick.MoveToElement(canvasElement, seatDetail.LeftCoord, seatDetail.TopCoord);
            actionClick.Click();
            actionClick.Build();
            actionClick.Perform();
        }
        //保留
        public ActionResult Save(int id)
        {
            SeatDetail seatDetail = Entity.SeatDetail.FirstOrDefault(a => a.Id == id);

            seatDetail.State = "保留";
            Entity.Entry(seatDetail).State = EntityState.Modified;

            seatDetail.Seat.State               = "保留";
            seatDetail.Seat.SaveTime            = DateTime.Now.AddMinutes(30);
            Entity.Entry(seatDetail.Seat).State = EntityState.Modified;
            Entity.SaveChanges();
            return(RedirectToAction("OrderHistory"));
        }
        //继续就坐
        public ActionResult SitDown(int id)
        {
            SeatDetail seatDetail = Entity.SeatDetail.FirstOrDefault(a => a.Id == id);

            seatDetail.State = "正常";
            Entity.Entry(seatDetail).State = EntityState.Modified;

            seatDetail.Seat.State               = "使用中";
            seatDetail.Seat.SaveTime            = null;
            Entity.Entry(seatDetail.Seat).State = EntityState.Modified;

            Entity.SaveChanges();
            return(RedirectToAction("OrderHistory"));
        }
        //离座
        public ActionResult Exit(int id)
        {
            SeatDetail seatDetail = Entity.SeatDetail.FirstOrDefault(a => a.Id == id);

            seatDetail.State               = "离座";
            seatDetail.EndTime             = DateTime.Now;
            Entity.Entry(seatDetail).State = EntityState.Modified;

            seatDetail.Seat.State               = "空闲";
            seatDetail.Seat.SaveTime            = null;
            Entity.Entry(seatDetail.Seat).State = EntityState.Modified;
            Entity.SaveChanges();


            return(RedirectToAction("OrderHistory"));
        }
Beispiel #7
0
        private SeatDetail ConstructSeat(string classes, int height, int width)
        {
            string[] tempClass        = classes.Split(' ');
            string   color            = tempClass[tempClass.Length - 1];
            int      leftCoord        = width;
            int      topCoord         = height;
            var      seatDetailsClass = driver.FindElement(By.ClassName("ltd-seatplan__tooltip__seat"));
            string   seatNumber       = seatDetailsClass.Text;
            var      seatCostClass    = driver.FindElement(By.ClassName("ltd-seatplan__tooltip__seatdetails"));
            string   seatCost         = seatCostClass.Text;

            //splitting to get rid of the extra information provided on a few seats
            string[] tempCost = seatCost.Split('\r');
            seatCost = string.Empty;
            seatCost = tempCost[0];
            //remove the first character which holds the currency symbol
            seatCost = seatCost.Trim(new char[] { '$', '€', '¢', '£', '¥', '₽', '₪', '฿', '₴', '₫', '₹' });

            SeatDetail seatDetail = new SeatDetail(color, seatNumber, Convert.ToDouble(seatCost), leftCoord, topCoord);

            return(seatDetail);
        }
 public ActionResult Add(SeatDetail seatDetail)
 {
     return(View());
 }