private void OnTestCommand()
        {
            var  df   = Spots;
            Spot spot = new Spot()
            {
                Color      = Colors.Red,
                Height     = 26.0,
                Id         = 9088127,
                IsSelected = true,
                Price      = 1000,
                RowNum     = "1",
                SeatNum    = "28",
                SectorName = "4 сектор",
                SideName   = "Левая сторона",
                Width      = 26.0,
                X          = 851.0,
                Y          = 445.0
            };

            if (Spots.Contains(spot, new SpotIdComparer()))
            {
                var dfd = Spots.FirstOrDefault(x => x.Id == spot.Id);
                Spots.Remove(dfd);
            }
            else
            {
                Spots.Add(spot);
            }
        }
Exemple #2
0
        public override void Update(GameTime gt)
        {
            if ((Mouse.LeftMouseDown || Mouse.RightMouseDown) && Mouse.CanPress)
            {
                Point coords = GetCoordinates(Mouse.Position);

                if (Mouse.LeftMouseDown)
                {
                    if (SpotExists(coords))
                    {
                        foreach (int[] pair in Spots)
                        {
                            if (pair[0] == coords.X && pair[1] == coords.Y)
                            {
                                Spots.Remove(pair);

                                break;
                            }
                        }
                    }
                    else
                    {
                        Spots.Add(new int[2] {
                            coords.X, coords.Y
                        });
                    }

                    Console.WriteLine("\n=========================================\nNew Spots:");
                    Spots.ForEach(x => Console.WriteLine("\t\t\t\tnew int[] { " + x[0] + ", " + x[1] + " },"));
                }
                else
                {
                    if (SpotExists(coords))
                    {
                        if (ObstacleExists(coords.X, coords.Y))
                        {
                            foreach (int[] pair in Obstacles)
                            {
                                if (pair[0] == coords.X && pair[1] == coords.Y)
                                {
                                    Obstacles.Remove(pair);

                                    break;
                                }
                            }
                        }
                        else
                        {
                            Obstacles.Add(new int[2] {
                                coords.X, coords.Y
                            });
                        }

                        Console.WriteLine("\n=========================================\nNew Obstacles:");
                        Obstacles.ForEach(x => Console.WriteLine("\t\t\t\tnew int[] { " + x[0] + ", " + x[1] + " },"));
                    }
                }
            }
        }
        /// <summary>
        /// Locks seats
        /// </summary>
        private void LockSeats(Spot[] spots)
        {
            List <Seat> seats = new List <Seat>();

            foreach (Spot spot in spots)
            {
                Seat seat = new Seat();
                seat.Id          = spot.Id;
                seat.ReserveDate = ReserveDate;
                seats.Add(seat);
            }

            List <Seat> lockedSeats = Data.Access.LockSeats(seats);

            if (lockedSeats != null)
            {
                HashSet <int> writerIds = new HashSet <int>(lockedSeats.Select(x => x.Id));
                seats.RemoveAll(x => writerIds.Contains(x.Id));

                foreach (Seat s in seats)
                {
                    SelectedSpots.Remove(SelectedSpots.Single(i => i.Id == s.Id));
                    Spots.Remove(Spots.Single(i => i.Id == s.Id));
                }

                int     counter = 0;
                decimal price   = 0;
                foreach (Spot spot in SelectedSpots)
                {
                    counter++;
                    price      += spot.Price;
                    spot.ItemId = counter;
                }
                StatusText      = String.Format("Удерживается {0} мест на сумму {1}", SeatsCount.ToString("### ##0"), SeatsAmount.ToString("C0"));
                OperationResult = String.Format("Выбрано мест {0} на сумму {1}", counter, price.ToString("C"));
            }
        }