示例#1
0
 public SeatEvent(Seat seat, DateTime start, DateTime end)
     : base(start, end)
 {
     Seat = seat;
     Start = start;
     End = end;
 }
示例#2
0
文件: Main.cs 项目: rsarwas/BridgeIt
 private static List<Trick> TestTricks(Suit trump, Seat declarer)
 {
     //D = declarer's team, d = defender's team
     var tricks = new List<Trick>(13);
     Seat lead = declarer.GetNextSeat(); //Lead:d, Win: D
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.TwoOfClubs, Deck.FiveOfClubs, Deck.FourOfClubs, Deck.ThreeOfClubs}));
     lead = lead.GetNextSeat();  // Lead:D, Win:d
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.EightOfClubs, Deck.NineOfClubs, Deck.SevenOfClubs, Deck.SixOfClubs}));
     lead = lead.GetNextSeat();  // Lead:d, Win:d
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.AceOfClubs, Deck.KingOfClubs, Deck.QueenOfClubs, Deck.JackOfClubs}));
     //lead = lead.GetNextSeat();  // Lead:d, Win:d
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.TenOfClubs, Deck.TwoOfDiamonds, Deck.ThreeOfDiamonds, Deck.FourOfDiamonds}));
     //lead = lead.GetNextSeat();  // Lead:d, Win:D
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.FiveOfDiamonds, Deck.EightOfDiamonds, Deck.SixOfDiamonds, Deck.SevenOfDiamonds}));
     lead = lead.GetNextSeat();  // Lead:D, Win:D
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.KingOfDiamonds, Deck.QueenOfDiamonds, Deck.JackOfDiamonds, Deck.TenOfDiamonds}));
     //lead = lead.GetNextSeat();  // Lead:D, Win:d
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.TwoOfHearts, Deck.FourOfHearts, Deck.AceOfDiamonds, Deck.ThreeOfHearts}));
     lead = lead.GetNextSeat();  // Lead:d, Win:D
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.FiveOfHearts, Deck.EightOfHearts, Deck.SixOfHearts, Deck.SevenOfHearts}));
     lead = lead.GetNextSeat();  // Lead:D, Win:d
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.NineOfHearts, Deck.QueenOfHearts, Deck.TenOfHearts, Deck.JackOfHearts}));
     lead = lead.GetNextSeat();  // Lead:d, Win:D
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.KingOfHearts, Deck.AceOfHearts, Deck.AceOfSpades, Deck.KingOfSpades}));
     lead = lead.GetNextSeat();  // Lead:D, Win:D
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.NineOfDiamonds, Deck.QueenOfSpades, Deck.JackOfSpades, Deck.TenOfSpades}));
     //lead = lead.GetNextSeat();  // Lead:D, Win:d
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.EightOfSpades, Deck.NineOfSpades, Deck.SevenOfSpades, Deck.SixOfSpades}));
     lead = lead.GetNextSeat();  // Lead:d, Win:D
     tricks.Add(Trick.FromCards(trump, lead, new[] {Deck.FourOfSpades, Deck.FiveOfSpades, Deck.ThreeOfSpades, Deck.TwoOfSpades}));
     //Score D: 7, d: 6
     return tricks;
 }
示例#3
0
        public void IsStuck_PlaceOnePossible_ReturnsFalse()
        {
            Seat seat = new Seat();

            seat.Positions[0].Add(new Card(1, Suit.Diamonds));

            Assert.IsFalse(seat.IsStuck);
        }
示例#4
0
文件: Call.cs 项目: rsarwas/BridgeIt
 public static Call FromString(Seat bidder, string s)
 {
     string lower = s.Trim().ToLower();
     if ("pass".StartsWith(lower))
         return new Call(bidder, CallType.Pass);
     if ("double".StartsWith(lower))
         return new Call(bidder, CallType.Double);
     if ("redouble".StartsWith(lower))
         return new Call(bidder, CallType.Redouble);
     return new Call(bidder, CallType.Bid, Bid.FromString(s));
 }
示例#5
0
        static void Main(string[] args)
        {
            Seat seat = new Seat("1A", 300, false);
            SeatChart seed = new SeatChart();
            seed.AddToList(seed.SeedSeatChart(5));
            List<Passenger> flightManifest = new List<Passenger>();
            Passenger initPassenger = new Passenger("", seat);
            flightManifest.Add(initPassenger);

            //passenger chooses origin/destination
            //passenger buys ticket

            //Repeat to fill plane
            // create seatchart for flight
            Origin origin = new Origin("Lima,Peru");
            Destination destination = new Destination("Bogota,Columbia");

            //create flight/airplane
            AirPlane airplane = new AirPlane(100, 300, true, "schedule");
            Flight flight = new Flight(airplane, 4345, origin, destination, flightManifest);




            //


            TextWriter writer = new StreamWriter("Manifest.txt", true);
            writer.Write(seat.getSeatName());
            writer.Close();
            
            




            //Dan.Name = "Dan";
            //Seat seat1 = new Seat("A1", 300, true);
            //Origin Milwaukee = new Origin("Milwaukee");
            //Destination SanDiego = new Destination("San Diego");
            //AirPlane airplane = new AirPlane();
            //Itinerary<object> itinerary = new Itinerary<object>(Milwaukee,SanDiego,airplane,Dan,seat1);
            //MyFileWriter mf = new MyFileWriter();
            //SeatChart seatChart = new SeatChart();
            //Passenger Adam = new Passenger("Adam",seat1);
            //seatChart.populateSeatChart();
            //seatChart.BuySeat(Adam);
            //seatChart.GetAvailableSeats();
            //Console.WriteLine(Adam.ChosenSeat.getSeatName());
            //mf.WriteToFile(Dan,Milwaukee,SanDiego);
 
        
            
        }
示例#6
0
文件: Score.cs 项目: rsarwas/BridgeIt
 public Score(Seat declarer, Contract contract, IEnumerable<Trick> tricks, Vulnerability vulnerability)
 {
     //FIXME add error checking
     Declarer = declarer;
     Contract = contract;
     Vulnerability = vulnerability;
     _tricks = tricks.ToList();
     _vulnerable = Declarer.IsVulnerable(vulnerability);
     TricksTaken = GetTricksTaken();
     TricksDefeated = contract.Bid.Tricks - TricksTaken; //todo limit to positive numbers ??
     ContractScore = GetContractScore();
 }
示例#7
0
文件: SeatLogic.cs 项目: Sryn/Movie6
 public static void insertSeat(int rid, string name, int rows, int columns)
 {
     var context = new MovieTheaterEntities();
     Seat st = new Seat();
     st.Seat_Name = name;
     st.Room_ID = rid;
     st.Rows = rows;
     st.Columns = columns;
     st.Active_Indicator = true;
     st.Update_Datetime = DateTime.Today;
     context.Seat.Add(st);
     context.SaveChanges();
 }
示例#8
0
    public override void Paint(Seat seat)
    {
        Bounds bounds = AreaBoardManager.Instance.GetBounds ();

        System.Random random = new System.Random();
        float px = (float)random.NextDouble () * bounds.size.x;
        float py = (float)random.NextDouble () * bounds.size.y;
        float nx = px - bounds.center.x - bounds.size.x/2;
        float ny = py - bounds.center.y - bounds.size.y/2;

        Vector2 newPosition = new Vector2(nx, ny);
        seat.AddCircle (new Circle(newPosition, radius));
    }
示例#9
0
文件: Call.cs 项目: rsarwas/BridgeIt
        public Call(Seat bidder, CallType type, Bid bid = null)
        {
            if (bidder == Seat.None)
                throw new ArgumentException("Bidder must not be none.");
            if (type == CallType.None)
                throw new ArgumentException("Call type must not be none.");
            if (type == CallType.Bid && bid == null)
                throw new ArgumentException("Bid must not be null when call type is bid.");

            Bidder = bidder;
            CallType = type;
            Bid = bid;
        }
示例#10
0
        public void IsStuck_PlaceTwoPossible_ReturnsFalse()
        {
            Seat seat = new Seat();

            seat.Positions[0].Add(new Card(1, Suit.Diamonds));
            seat.Positions[1].Add(new Card(2, Suit.Clubs));
            seat.Positions[2].Add(new Card(3, Suit.Hearts));
            seat.Positions[3].Add(new Card(4, Suit.Spades));
            seat.Positions[4].Add(new Card(5, Suit.Clubs));
            seat.Positions[5].Add(new Card(5, Suit.Diamonds));
            seat.Positions[6].Add(new Card(4, Suit.Diamonds));
            seat.Positions[7].Add(new Card(3, Suit.Spades));
            seat.Positions[8].Add(new Card(6, Suit.Diamonds));
            Assert.IsFalse(seat.IsStuck);
        }
    public StandUpAction(GameObject actor, Seat seat)
        : base(actor)
    {
        this.seat = seat;
        this.seatType = seat.GetType();
        InitAnimationInfo("stand_up_" + seatType, WrapMode.Once, Emotion.BodyParts.FACE);
        InitInteractionInfo(true, true, false);

        seatHook = CharacterAnimator.FindChild(actor, seatType + "_hook");
        if (actor.name.Equals("Abby")) {
            FModManager.StartEventAtCamera(FModLies.EVENTID_LIES_ACTIONS_CHAIR);
        } else {
            FModManager.StartEvent(FModLies.EVENTID_LIES_ACTIONS_CHAIR, actor.transform.position);
        }
    }
示例#12
0
 //FIXME Use ITable this by adding events to ITable
 public void JoinTable(Table table)
 {
     if (table == null)
         throw new ArgumentNullException("table");
     SignupForMessages(table);
     try
     {
         _mySeat = table.SitDown(this);
     }
     catch (Exception)
     {
         UnsubscribeToMessages(table);
         throw;
     }
     _table = table;
 }
示例#13
0
 static void Main(string[] args)
 {
     Passenger Dan = new Passenger();
     Dan.Name = "Dan";
     Seat seat = new Seat("3A", 250);
     Origin Milwaukee = new Origin("Milwaukee");
     Destination SanDiego = new Destination("San Diego");
     AirPlane airplane = new AirPlane();
     Itinerary<object> itinerary = new Itinerary<object>(Milwaukee,SanDiego,airplane,Dan,seat);
     MyFileWriter mf = new MyFileWriter();
     SeatChart seatChart = new SeatChart();
     seatChart.populateSeatChart();
     mf.WriteToFile(Dan,Milwaukee,SanDiego);   
 
     
 }
示例#14
0
    private void PaintLine(Seat seat, Vector2 from, Vector2 to)
    {
        float distance = Vector2.Distance (from, to);

        // FIXME: avoid div 0.
        if (distance <= 0) {
            distance = 0.001f;
        }

        int step = (int)((distance/ radius) * 2.0f + 1);
        float stepX = (to.x - from.x) / step;
        float stepY = (to.y - from.y) / step;

        for (int i = 0; i<step; i++) {
            Vector2 newPosition = new Vector2(from.x + stepX * i, from.y + stepY * i);
            seat.AddCircle (new Circle(newPosition, radius));
        }
    }
        public void NotifyThatReservationIsReady(User user, Seanse seanse, Seat seat)
        {
            string message = _templateRepository.GetReservationPlainTextMessage(seanse, seat);
            if (!CanSendSmsNotification(user))
            {
                return;
            }

            SmsToSend queuedSms = GetSmsFromQueue(user.Id);
            if (queuedSms != null)
            {
                queuedSms.Message = message + " " + queuedSms.Message;
            }
            else
            {
                QueueSms(user, message);
            }
        }
        public void NotifyThatReservationIsReady(User user, Seanse seanse, Seat seat)
        {
            string message = _templateRepository.GetReservationHtmlMessage(seanse, seat);
            if (!CanSendEmailNotification(user))
            {
                return;
            }

            MailToSend queuedEmail = GetMailFromQueue(user.Id);
            if (queuedEmail != null)
            {
                queuedEmail.Subject = "You have reserved seat and won free ticket";
                queuedEmail.Content = message + Environment.NewLine + queuedEmail.Content;
            }
            else
            {
                QueueEmail(user, "You have reserved seat", message);
            }
        }
示例#17
0
    public override void Paint(Seat seat)
    {
        Bounds bounds = AreaBoardManager.Instance.GetBounds ();

        System.Random random = new System.Random();
        float px, py, nx, ny;
        bool useX = Mathf.Abs(position.x - bounds.center.x) >= Mathf.Abs(position.y - bounds.center.y);
        bool useMax = useX ? (position.x - bounds.center.x) < 0 : (position.y - bounds.center.y) < 0;

        if (useX) {
            px = useMax ? bounds.size.x : 0;
            py = (float)random.NextDouble () * bounds.size.y;
        } else {
            px = (float)random.NextDouble () * bounds.size.x;
            py = useMax ? bounds.size.y : 0;
        }

        nx = px - bounds.center.x - bounds.size.x/2;
        ny = py - bounds.center.y - bounds.size.y/2;

        Vector2 newPosition = new Vector2(nx, ny);

        PaintLine (seat, position, newPosition);
    }
        private bool CustomFilter(object obj)
        {
            Seat seat = obj as Seat;

            return(!seat.Active);
        }
示例#19
0
 void OnPedAssignedToVehicle_Radio(Ped ped, Seat seat)
 {
     m_radio_pedAssignedToVehicleLastFrame = true;
 }
        public async Task <ServiceResponse <Reservation> > AddReservation(AddReservationDto newReservation)
        {
            ServiceResponse <Reservation> serviceResponse = new ServiceResponse <Reservation>();

            try
            {
                #region nzm
                //prvo provera da li ima mesta na letovima

                /*Flight dbDeparting = await _context.Flights.FirstOrDefaultAsync(f => f.Id == newReservation.DepartingFlight.Id);
                 * if (dbDeparting.SeatsLeft == 0) //nema mesta vise
                 * {
                 *  serviceResponse.Message = "There's no more seats left at this aircraft.";
                 *  serviceResponse.Success = false;
                 *  return serviceResponse;
                 * }
                 * else
                 * {
                 *  dbDeparting.SeatsLeft--;//samo za jedan, jer nije implementirano za vise korisnika odjednom
                 *  _context.Flights.Update(dbDeparting);
                 *  await _context.SaveChangesAsync();
                 * }
                 *
                 * if (newReservation.ReturningFlight != null)
                 * {
                 *  Flight dbReturning = await _context.Flights.FirstOrDefaultAsync(f => f.Id == newReservation.ReturningFlight.Id);
                 *  if (dbReturning.SeatsLeft == 0) //nema mesta vise
                 *  {
                 *      serviceResponse.Message = "There's no more seats left at this aircraft.";
                 *      serviceResponse.Success = false;
                 *      return serviceResponse;
                 *  }
                 *  else
                 *  {
                 *      dbReturning.SeatsLeft--;
                 *      _context.Flights.Update(dbReturning);
                 *      await _context.SaveChangesAsync();
                 *  }
                 * }*/
                #endregion nzm

                User user = await _context.Users.Include(u => u.Reservations).FirstOrDefaultAsync(u => u.Id == GetUserId());

                newReservation.User = user;

                // OVO JE NOVO
                Seat departingSeat = await _context.Seats.AsNoTracking().FirstOrDefaultAsync(s => s.Id == newReservation.DepartingFlightSeat.Id);

                //departingSeat.State = SeatState.TAKEN;
                newReservation.DepartingFlightSeat = departingSeat;

                if (newReservation.ReturningFlightSeat != null)
                {
                    Seat returningSeat = await _context.Seats.AsNoTracking().FirstOrDefaultAsync(s => s.Id == newReservation.ReturningFlightSeat.Id);

                    //returningSeat.State = SeatState.TAKEN;
                    newReservation.ReturningFlightSeat = returningSeat;
                }

                Reservation reservation = _mapper.Map <Reservation>(newReservation);

                user.Reservations.Add(reservation);

                /*_context.Seats.Update(newReservation.DepartingFlightSeat);
                *  if (newReservation.ReturningFlightSeat != null)
                *   _context.Seats.Update(newReservation.ReturningFlightSeat);*/

                _context.Users.Update(user);
                await _context.SaveChangesAsync();

                Reservation forResponse = _mapper.Map <Reservation>(newReservation);
                serviceResponse.Data = forResponse;
                #region email
                //poslati imejl
                string pattern = @"Reservation details..
                                   Flight #1 : Origin: {0} | Destination: {1} | Takeoff time: {2} | Landing time: {3} | Duration: {4}.
                                   ";

                string emailData = string.Format(pattern, newReservation.DepartingFlight.Origin, newReservation.DepartingFlight.Destination,
                                                 newReservation.DepartingFlight.TakeoffTime, newReservation.DepartingFlight.LandingTime, newReservation.DepartingFlight.Duration);

                if (newReservation.ReturningFlight != null)
                {
                    string pattern2   = @"
                                   Flight #2 : Origin: {0} | Destination: {1} | Takeoff time: {2} | Landing time: {3} | Duration: {4}.
                                   ";
                    string emailData2 = string.Format(pattern2, newReservation.ReturningFlight.Origin, newReservation.ReturningFlight.Destination,
                                                      newReservation.ReturningFlight.TakeoffTime, newReservation.ReturningFlight.LandingTime, newReservation.ReturningFlight.Duration);

                    emailData = emailData + emailData2;
                }

                var message = new MimeMessage();
                message.From.Add(new MailboxAddress("Booking details", "*****@*****.**"));
                message.To.Add(new MailboxAddress("Luka", "*****@*****.**"));
                message.Subject = "Booking details";
                message.Body    = new TextPart("plain")
                {
                    Text = emailData
                };

                using (var client = new MailKit.Net.Smtp.SmtpClient())
                {
                    client.Connect("smtp.gmail.com", 587, false);

                    //SMTP server authentication if needed
                    client.Authenticate("rluka996", "kostadin");

                    client.Send(message);

                    client.Disconnect(true);
                }
                #endregion email
            }
            catch (Exception ex)
            {
                serviceResponse.Message = ex.Message;

                serviceResponse.Success = false;
            }
            return(serviceResponse);

            #region druginacin

            /*
             * ServiceResponse<List<Reservation>> serviceResponse = new ServiceResponse<List<Reservation>>();
             * try
             * {
             *  User user = await _context.Users.Include(u => u.Reservations).FirstOrDefaultAsync(u => u.Id == GetUserId());
             *  newReservation.User = user;
             *  Reservation reservation = _mapper.Map<Reservation>(newReservation);
             *  await _context.Reservations.AddAsync(reservation);
             *  //await _context.SaveChangesAsync();
             *
             *  serviceResponse.Data = user.Reservations.ToList();
             * }
             * catch (Exception ex)
             * {
             *  serviceResponse.Message = ex.Message;
             *  serviceResponse.Success = false;
             * }
             * return serviceResponse;
             */
            #endregion druginacin
        }
 public Task <ServiceResponse <Seat> > UpdateInvitationSeatState(Seat seat)
 {
     throw new NotImplementedException();
 }
示例#22
0
 public Player(string name, ChipColor color, Seat seat)
 {
     ChipColor = color;
     Name = name;
     Seat = seat;
 }
示例#23
0
        private void btnSeat_Click(object sender, EventArgs e)
        {
            Button button = sender as Button;
            string[] ticketPlace = button.Tag.ToString().Split(new string[] { "row", "position" },
                StringSplitOptions.RemoveEmptyEntries);
            int row = int.Parse(ticketPlace[0]);
            int position = int.Parse(ticketPlace[1]);

            bool booked = false;
            int bookedSeatIndex = -1;

            for (int i = 0; i < this.userSeats.Count; i++)
            {
                if (this.userSeats[i].Row == row && this.userSeats[i].Position == position)
                {
                    booked = true;
                    bookedSeatIndex = i;
                    break;
                }
            }

            if (booked)
            {
                this.userSeats.RemoveAt(bookedSeatIndex);
                button.Background = freeSeat.Background;
            }
            else
            {
                Seat s = new Seat();
                s.Row = row;
                s.Position = position;
                s.ScheduleId = SingletonSchedule.Schedule.Id;
                s.UserId = SingletonUser.User.Id;
                s.Email = SingletonUser.User.Email;

                this.userSeats.Add(s);
                button.Background = bookedSeat.Background;
            }
        }
示例#24
0
        /// <summary>
        /// N.B. this is not how you would override equals in a production environment. :)
        /// </summary>
        public override bool Equals(object obj)
        {
            Seat other = obj as Seat;

            return(Coach == other.Coach && SeatNumber == other.SeatNumber);
        }
示例#25
0
 public void SetCurrentSeat(Seat s)
 {
     currentSeat = s;
 }
示例#26
0
        private void Leave(Table table)
        {
            if (table != _table)
                return; // we are not at this table

            //Don't leave while you are still responding to messages.
            UnsubscribeToMessages(table);
            table.Quit(this);
            _table = null;
            _seat = Seat.None;
        }
示例#27
0
 private void Join(Table table)
 {
     //Once you sit down, table will start sending you messages.
     SignupForMessages(table);
     _seat = table.SitDown(this);
     _table = table;
 }
示例#28
0
 public void Visit(Seat seat)
 {
     VisitSeat(seat.name, seat.capacity);
 }
示例#29
0
 public async Task Switchseat(Seat firstSeat, Seat secondSeat)
 {
     using (var client = HttpClientWithToken.GetClient()) {
         await client.PutAsync(new Uri($"https://localhost:44319/api/Seat/SwitchSeats?firstPassengerId={firstSeat.Passenger.Id.ToString()}&secondPassengerId={secondSeat.Passenger.Id.ToString()}", UriKind.Absolute), null);
     }
 }
示例#30
0
 public abstract void Paint(Seat seat);
 public PCStandUpAction(GameObject actor, Seat seat)
     : base(actor)
 {
     standUpAction = new StandUpAction(actor, seat);
 }
示例#32
0
        private void btnYes_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSeatNo.Text.Trim()))
            {
                toolTip1.SetToolTip(txtSeatNo, "请输入座位号!");
                toolTip1.Show("请输入座位号!", txtSeatNo, 5000);
                txtSeatNo.Text = "";
                return;
            }
            string          seatNo     = "";
            ReadingRoomInfo roomInfo   = clientObject.EnterOutLogData.Student.AtReadingRoom;
            string          roomNo     = roomInfo.No + "000";
            string          seatHeader = SeatComm.SeatNoToSeatNoHeader(roomInfo.Setting.SeatNumAmount, roomNo);

            seatNo = seatHeader + txtSeatNo.Text;
            //获取座位信息,并判断座位在该阅览室是否存在。
            Seat seat = T_SM_Seat.GetSeatInfoBySeatNo(seatNo);

            if (seat == null)
            {
                toolTip1.SetToolTip(txtSeatNo, "座位号输入有误,请输入正确的座位号!");
                toolTip1.Show("座位号输入有误,请输入正确的座位号!", txtSeatNo, 5000);
                txtSeatNo.Text = "";
                return;
            }
            if (seat.IsSuspended)
            {
                toolTip1.SetToolTip(txtSeatNo, "您选择的座位,已暂停使用,请重新选择!");
                toolTip1.Show("您选择的座位,已暂停使用,请重新选择!", txtSeatNo, 5000);
                txtSeatNo.Text = "";
                return;
            }
            if (seat.ReadingRoomNum != roomInfo.No)
            {
                toolTip1.SetToolTip(txtSeatNo, string.Format("座位{0}在该阅览室不存在", txtSeatNo.Text));
                toolTip1.Show(string.Format("座位{0}在该阅览室不存在", txtSeatNo.Text), txtSeatNo, 5000);
                txtSeatNo.Text = "";
                return;
            }

            SeatManage.EnumType.EnterOutLogType logType = SeatManage.Bll.T_SM_EnterOutLog.GetSeatUsedState(seatNo);

            //TODO:还需检测座位是否被预约 SeatManage.Bll.T_SM_EnterOutLog
            if (logType == SeatManage.EnumType.EnterOutLogType.None || logType == SeatManage.EnumType.EnterOutLogType.Leave)
            {
                //根据座位号获取进出记录的状态,如果为None或者为Leave,则锁定座位
                SeatManage.EnumType.SeatLockState lockResult = SeatManage.Bll.T_SM_Seat.LockSeat(seatNo);
                if (lockResult == SeatManage.EnumType.SeatLockState.NotExists)
                {
                    toolTip1.SetToolTip(txtSeatNo, "座位号不存在");
                    toolTip1.Show("座位号不存在", txtSeatNo, 5000);
                    return;
                }
                else if (lockResult == SeatManage.EnumType.SeatLockState.UnLock)
                {
                    toolTip1.SetToolTip(txtSeatNo, "座位正在被其他读者选择");
                    toolTip1.Show("座位正在被其他读者选择", txtSeatNo, 5000);
                    txtSeatNo.Text = "";
                    return;
                }
                else if (lockResult == SeatManage.EnumType.SeatLockState.Locked)
                {
                    this._seatNo = seatNo;
                    this.Close();
                    this.Dispose();
                }
            }
            else if (logType == SeatManage.EnumType.EnterOutLogType.BespeakWaiting)
            {
                toolTip1.SetToolTip(txtSeatNo, "已被其他读者预约");
                toolTip1.Show("已被其他读者预约", txtSeatNo, 5000);
                txtSeatNo.Text = "";
                return;
            }
            else
            {
                toolTip1.SetToolTip(txtSeatNo, "座位正在被使用");
                toolTip1.Show("座位正在被使用", txtSeatNo, 5000);
                txtSeatNo.Text = "";
                return;
            }
            //}
            //else
            //{
            //    toolTip1.SetToolTip(txtSeatNo, "请输入最后四位座位号");
            //    toolTip1.Show("请输入座位号",txtSeatNo,5000);
            //}
        }
 public PCSitDownAction(GameObject actor, Seat seat)
     : base(actor)
 {
     InitMovementInfo(seat.gameObject, DistanceConstants.SIT_DOWN_DISTANCE, true, false, false);
 }
示例#34
0
 public SeatReservationFailed(Guid customer, Seat seat)
 {
     Customer = customer;
     Seat     = seat;
 }
示例#35
0
文件: Trick.cs 项目: rsarwas/BridgeIt
 public static Trick FromCards(Suit trump, Seat lead, IEnumerable<Card> cards)
 {
     Trick trick = new Trick(trump);
     Seat player = lead;
     foreach (var card in cards)
     {
         trick.AddCard(card, player);
         player = player.GetNextSeat();
     }
     return trick;
 }
示例#36
0
        //예약하기
        protected void Button2_Click(object sender, EventArgs e)
        {
            List <Tuple <string, string> > TryBookingSeats = new List <Tuple <string, string> >();

            #region 예매정보없거나 지정한 인원와 다르면 리턴
            if (SelectedMovieID == "" || SelectedPlayDate == "" || SelectedTheater == "")
            {
                return;
            }
            //원래 chkbox에 changed on 일때 remainTicket의 값을 변동해서 0인지 검사하려고했지만
            //동적으로 생성된 컨트롤에대해 이벤트를 받는게 해결이 되지 않아 임시방편으로
            //enable상태이면서 checked숫자로 비교한다.
            int checkedBoxCount = 0;
            foreach (TableRow tableRow in Table1.Rows)
            {
                foreach (TableCell tableCell in tableRow.Cells)
                {
                    if (tableCell.Controls.Count == 1)
                    {
                        CheckBox chkBox = (CheckBox)tableCell.Controls[0];
                        if (chkBox.Enabled && chkBox.Checked)
                        {
                            checkedBoxCount++;
                            string[] RowAndNumber = chkBox.ID.Split(new char[] { '열', '번' });
                            TryBookingSeats.Add(new Tuple <string, string>(RowAndNumber[0], RowAndNumber[1]));
                        }
                    }
                }
            }
            //checkbox가 더 많거나 적으므로 예매를 취소하고 확인해달라는 메시지를 보내야함.
            if (remainTicket != checkedBoxCount)
            {
                return;
            }
            #endregion

            //TODO : 예약 객체 생성시 점검사항들
            //      1. 포인트가 사람수만큼 결제가능한지 확인합니다.
            //      2. 예약하는동안 선택한 좌석(들)이 예매가 되었는지 확인.
            //      3. 관람등급과 고객나이 확인
            //      4. 예매객체 생성
            //      5. 포인트 사용내역 객체 생성
            //      6. Seat의 예약상태를 True로 변경한다.
            //      7. 예약할경우 MovieSchedule의 RemainSeat값도 줄여줘야함.

            string Command = "";
            List <Tuple <string, object> > Params;
            SqlDataReader reader;
            List <Movie>  SelcetedMovieObject = null;
            int           LastlyRemaindPoint  = 0;
            #region 1
            Command = "SELECT * FROM Point WHERE ID=@id ORDER BY Occuredatetime DESC";
            Params  = new List <Tuple <string, object> >();
            Params.Add(new Tuple <string, object>("@id", LoginedMember.ID));

            reader = dbManager.GetDataList(Command, Params);
            List <dataSet.Point> points = dataSet.Point.SqlDataReaderToMember(reader);
            if (points == null || points.Count == 0)
            {
                return;
            }
            int totalPrice = remainTicket * Constant.MoviePrice;
            if (Convert.ToInt32(points[0].Remainvalue) < totalPrice)
            {
                return;
            }
            LastlyRemaindPoint = Convert.ToInt32(points[0].Remainvalue);
            Params.Clear();
            #endregion
            #region 2
            Command = "Select * From Seat Where " +
                      "TheaterID = @TheaterID AND Playtime = @Playtime AND Seatrow = @Seatrow AND Seatnumber = @Seatnumber";
            foreach (Tuple <string, string> TryBookingSeat in TryBookingSeats)
            {
                Params.Add(new Tuple <string, object>("@TheaterID", SelectedTheater));
                Params.Add(new Tuple <string, object>("@Playtime", SelectedPlayDate));
                Params.Add(new Tuple <string, object>("@Seatrow", TryBookingSeat.Item1));
                Params.Add(new Tuple <string, object>("@Seatnumber", TryBookingSeat.Item2));
                reader = dbManager.GetDataList(Command, Params);
                List <Seat> seat = Seat.SqlDataReaderToSeat(reader);
                if (seat == null || seat.Count == 0 || seat[0].Isbooked == "True")
                {
                    return;
                }
                Params.Clear();
            }
            #endregion
            #region 3
            Command = "Select * From Movie Where MovieID = @MovieID";
            Params.Add(new Tuple <string, object>("@MovieId", SelectedMovieID));
            reader = dbManager.GetDataList(Command, Params);
            SelcetedMovieObject = Movie.SqlDataReaderToMember(reader);
            if (SelcetedMovieObject == null || SelcetedMovieObject.Count == 0)
            {
                return;
            }
            if (Convert.ToInt32(LoginedMember.Age) < Convert.ToInt32(SelcetedMovieObject[0].Viewingclass))
            {
                return;
            }
            Params.Clear();
            #endregion
            #region 4
            Command = "insert into Booking(ID, MovieID, TheaterID, Playdatetime, Seatrow, Seatnumber, Moviename, Bookedcount, Viewingclass)" +
                      "values(@ID, @MovieID, @TheaterID, @Playdatetime, @Seatrow, @Seatnumber, @Moviename, @Bookedcount, @Viewingclass)";
            foreach (Tuple <string, string> TryBookingSeat in TryBookingSeats)
            {
                Params.Add(new Tuple <string, object>("@ID", LoginedMember.ID.Trim()));
                Params.Add(new Tuple <string, object>("@MovieID", SelectedMovieID.Trim()));
                Params.Add(new Tuple <string, object>("@TheaterID", SelectedTheater.Trim()));
                Params.Add(new Tuple <string, object>("@Playdatetime", SelectedPlayDate));
                Params.Add(new Tuple <string, object>("@Seatrow", TryBookingSeat.Item1));
                Params.Add(new Tuple <string, object>("@Seatnumber", TryBookingSeat.Item2));
                Params.Add(new Tuple <string, object>("@Moviename", SelcetedMovieObject[0].Moviename));
                Params.Add(new Tuple <string, object>("@Bookedcount", remainTicket));
                Params.Add(new Tuple <string, object>("@Viewingclass", SelcetedMovieObject[0].Viewingclass));
                if (!dbManager.DoCommand(Command, Params))
                {
                    ;//TODO : 예약 실패 로직(미완성).
                }
                Params.Clear();
            }
            #endregion
            #region 5
            Command = "insert into Point(ID, Occuredatetime, Usedvalue, Rechargedvalue, Remainvalue)" +
                      "values(@ID, @Occuredatetime, @Usedvalue, @Rechargedvalue, @Remainvalue)";
            Params.Add(new Tuple <string, object>("@ID", LoginedMember.ID));
            Params.Add(new Tuple <string, object>("@Occuredatetime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            Params.Add(new Tuple <string, object>("@Usedvalue", remainTicket * Constant.MoviePrice));
            Params.Add(new Tuple <string, object>("@Rechargedvalue", 0));
            Params.Add(new Tuple <string, object>("@Remainvalue", LastlyRemaindPoint - remainTicket * Constant.MoviePrice));
            if (!dbManager.DoCommand(Command, Params))
            {
                ;//TODO : 예약 실패 로직(미완성).
            }
            Params.Clear();
            #endregion
            #region 6
            Command = Command = "Update Seat Set Isbooked = @Isbooked " +
                                "Where TheaterID = @TheaterID AND Seatrow = @Seatrow AND Seatnumber = @Seatnumber AND Playtime = @Playtime";
            foreach (Tuple <string, string> TryBookingSeat in TryBookingSeats)
            {
                Params.Add(new Tuple <string, object>("@Isbooked", "True"));
                Params.Add(new Tuple <string, object>("@TheaterID", SelectedTheater));
                Params.Add(new Tuple <string, object>("@Seatrow", TryBookingSeat.Item1));
                Params.Add(new Tuple <string, object>("@Seatnumber", TryBookingSeat.Item2));
                Params.Add(new Tuple <string, object>("@Playtime", SelectedPlayDate));
                if (!dbManager.DoCommand(Command, Params))
                {
                    ;//TODO : 예약 실패 로직(미완성).
                }
                Params.Clear();
            }
            #endregion
            #region 7
            //일단 기존남은 좌석 데이터를 가져와야함.
            int RemainSeatCount = 0;
            Command = "Select * From Movieschedule " +
                      "Where MovieID = @MovieId AND TheaterID = @TheaterID AND Playtime = @Playtime";
            Params.Add(new Tuple <string, object>("@MovieId", SelectedMovieID));
            Params.Add(new Tuple <string, object>("@TheaterID", SelectedTheater));
            Params.Add(new Tuple <string, object>("@Playtime", SelectedPlayDate));
            reader = dbManager.GetDataList(Command, Params);
            List <Movieschedule> movieschedule = Movieschedule.SqlDataReaderToMember(reader);
            if (movieschedule == null || movieschedule.Count != 1)
            {
                return;
            }
            RemainSeatCount = Convert.ToInt32(movieschedule[0].Seatremained);
            if (RemainSeatCount == 0)
            {
                return;
            }

            Params.Clear();
            Command = "Update Movieschedule Set Seatremained = @Seatremained " +
                      "Where MovieID = @MovieId AND TheaterID = @TheaterID AND Playtime = @Playtime";
            Params.Add(new Tuple <string, object>("@Seatremained", RemainSeatCount - remainTicket));
            Params.Add(new Tuple <string, object>("@MovieId", SelectedMovieID));
            Params.Add(new Tuple <string, object>("@TheaterID", SelectedTheater));
            Params.Add(new Tuple <string, object>("@Playtime", SelectedPlayDate));
            if (!dbManager.DoCommand(Command, Params))
            {
                ;//TODO : 예약 실패 로직(미완성).
            }
            else
            {
                Response.Redirect("BookingList.aspx");
            }
            #endregion
        }
    public void ReserveSeat()
    {
        char ticketType         = char.MinValue;
        byte passengersTogether = 0;
        int  maxPassengersTogether;
        bool inputOk = false;

        while (ticketType != 'F' && ticketType != 'S')
        {
            Console.Write("Enter the ticket type (F = First Class, S = Second Class): ");
            ticketType = char.ToUpper(Console.ReadLine()[0]);
        }
        if (ticketType == 'F')
        {
            maxPassengersTogether = 2;
        }
        else
        {
            maxPassengersTogether = 3;
        }
        while (!inputOk && (passengersTogether < 1 ||
                            passengersTogether > maxPassengersTogether))
        {
            Console.Write("Enter the number of passengers traveling together (1 or {0}): ",
                          maxPassengersTogether);
            inputOk = byte.TryParse(Console.ReadLine(), out passengersTogether);
        }
        for (byte passengerNumber = 1;
             passengerNumber <= passengersTogether;
             passengerNumber++)
        {
            Console.Write("Passenger {0} full name (BLOCK CAPITAL): ", passengerNumber);
            string passengerName   = Console.ReadLine();
            Seat   seat            = null;
            string lastSeatAddress = null;
            // Choosen seat address must be valid (or else it will return null)
            // Choosen seat must match ticket type
            // Choosen seat must not be occupied
            while (seat == null ||
                   seat.Class != (ClassType)ticketType ||
                   seat.Status == SeatStatus.Occupied)
            {
                if (seat != null)
                {
                    if (seat.Class != (ClassType)ticketType)
                    {
                        Console.WriteLine("Seat does not match ticket type.");
                    }
                    if (seat.Status == SeatStatus.Occupied)
                    {
                        Console.WriteLine("This seat is occupied by {0}.",
                                          seat.Passenger);
                    }
                }
                else
                {
                    if (lastSeatAddress != null)
                    {
                        Console.WriteLine("Invalid seat address.");
                    }
                }
                Console.Write("Enter passenger seat (example: 1A): ");
                lastSeatAddress = Console.ReadLine().ToUpper();
                seat            = this[lastSeatAddress];
            }
            seat.Passenger = passengerName;
            Console.WriteLine("Seat {0} reserved for passenger {1}.",
                              seat.Position, seat.Passenger);
        }
        Console.WriteLine("Reservation complete.");
        Console.WriteLine();
    }
示例#38
0
        public async Task SaveAvailableSeats(List<Facet> facets, List<Seat> seats, List<Offer> offers, string bteId, string url)
        {
            foreach (var facet in facets)
            {
                var offer = offers.Where(x => facet.Offers.Any(z => z == x.OfferId)).ToList();
                foreach (var placeId in facet.Places)
                {
                    var place = seats.Where(x => x.Id == placeId).ToList();
                    foreach (var seat in place)
                    {
                        SetSeatInformation(seat, offer, facet);
                    }
                }
                if (facet.Available)
                {
                    foreach (var shape in facet.Shapes)
                    {
                        var standingSeats = seats.Where(x => x.IsStanding && x.Id == shape);
                        foreach (var seat in standingSeats)
                        {
                            SetSeatInformation(seat, offer, facet);
                        }

                    }
                }

            }

            var groups = seats.Where(x => !x.IsStanding).GroupBy(x => new { x.Section, x.Row }).ToList();
            var ticketGroups = new List<List<Seat>>();

            foreach (var group in groups)
            {
                var priceLevelId = group.FirstOrDefault()?.Offer?.PriceLevelId;
                var ticketGroup = new List<Seat>();
                Seat previousSeat = null;

                foreach (var seat in group)
                {
                    if (IsNextInGroup(seat, previousSeat, priceLevelId))
                    {
                        if (ticketGroup.Any())
                        {
                            ticketGroups.Add(ticketGroup);
                            ticketGroup = new List<Seat>();
                        }
                        priceLevelId = seat.Offer?.PriceLevelId;
                    }
                    if (seat.IsAvailable)
                    {
                        ticketGroup.Add(seat);
                        previousSeat = seat;
                    }
                }
                if (ticketGroup.Any())
                {
                    ticketGroups.Add(ticketGroup);
                }

            }

            var ticketsNumber = seats.Count(x => x.IsAvailable && !x.IsStanding);

            var standingGroups = seats.Where(x => x.IsStanding).ToList();
            foreach (var group in standingGroups)
            {
                ticketGroups.Add(new List<Seat>() { group });
            }

           // await SaveTicketGroups(ticketGroups, bteId, ticketsNumber, url);
        }
        public async Task <ServiceResponse <Reservation> > AddReservationQuick(QuickReservationDto newReservation) //UserID, DepartingFlight
        {
            ServiceResponse <Reservation> serviceResponse = new ServiceResponse <Reservation>();

            try
            {
                User user = await _context.Users.Include(u => u.Reservations).FirstOrDefaultAsync(u => u.Id == GetUserId());

                newReservation.User = user;

                Flight depFlight = await _context.Flights.AsNoTracking().Include(f => f.Seats).FirstOrDefaultAsync(f => f.Id == newReservation.DepartingFlight.Id);

                var depSeats = depFlight.Seats.Where(s => s.State == 0); //ovde su mi sad slobodna mesta

                Random random = new Random();

                List <int> seatIds = new List <int>();
                foreach (Seat seat in depSeats)
                {
                    seatIds.Add(seat.Id);
                }
                int randomIndex = random.Next(0, seatIds.Count);

                var randomSeatId = seatIds[randomIndex];
                // OVO JE NOVO
                Seat departingSeat = await _context.Seats.AsNoTracking().FirstOrDefaultAsync(s => s.Id == randomSeatId);

                newReservation.DepartingFlightSeat = departingSeat;

                Reservation reservation = _mapper.Map <Reservation>(newReservation);

                user.Reservations.Add(reservation);

                _context.Users.Update(user);
                await _context.SaveChangesAsync();

                Reservation forResponse = _mapper.Map <Reservation>(newReservation);
                serviceResponse.Data = forResponse;
                #region email
                //poslati imejl
                string pattern = @"Reservation details..
                                   Flight #1 : Origin: {0} | Destination: {1} | Takeoff time: {2} | Landing time: {3} | Duration: {4}.
                                   ";

                string emailData = string.Format(pattern, newReservation.DepartingFlight.Origin, newReservation.DepartingFlight.Destination,
                                                 newReservation.DepartingFlight.TakeoffTime, newReservation.DepartingFlight.LandingTime, newReservation.DepartingFlight.Duration);


                var message = new MimeMessage();
                message.From.Add(new MailboxAddress("Booking details", "*****@*****.**"));
                message.To.Add(new MailboxAddress("Luka", "*****@*****.**"));
                message.Subject = "Booking details";
                message.Body    = new TextPart("plain")
                {
                    Text = emailData
                };

                using (var client = new MailKit.Net.Smtp.SmtpClient())
                {
                    client.Connect("smtp.gmail.com", 587, false);

                    //SMTP server authentication if needed
                    client.Authenticate("rluka996", "kostadin");

                    client.Send(message);

                    client.Disconnect(true);
                }
                #endregion email
            }
            catch (Exception ex)
            {
                serviceResponse.Message = ex.Message;

                serviceResponse.Success = false;
            }
            return(serviceResponse);
        }
示例#40
0
        private void btnSatin_Click(object sender, EventArgs e)
        {
            //get all seat numbers
            List <string> selectedSeatList = new List <string>();

            if (int.Parse(txtBoxKoltukNo.Text) < 1 || int.Parse(txtBoxKoltukNo.Text) > 28 || txtBoxKoltukNo.Text == "")
            {
                MessageBox.Show("Geçerli bir koltuk numarası girin!");
                txtBoxKoltukNo.Text = "";
                return;
            }
            selectedSeatList.Add(txtBoxKoltukNo.Text);
            var txtBoxesSeatNumber = pnlEkKoltuk.Controls.OfType <TextBox>();

            foreach (TextBox tb in txtBoxesSeatNumber)
            {
                if (int.Parse(tb.Text) < 1 || int.Parse(tb.Text) > 28 || tb.Text == "")
                {
                    MessageBox.Show("Geçerli bir koltuk numarası girin!");
                    tb.Text = "";
                    return;
                }
                else
                {
                    selectedSeatList.Add(tb.Text);
                }
            }

            //seat check if empty, if not error
            if (seatEmpty(selectedSeatList)) //Seat Empty - BUY
            {
                //new user
                User nUser = new User();
                nUser.UserId       = Guid.NewGuid();
                nUser.Name         = txtBoxKullAd.Text;
                nUser.Email        = txtBoxMail.Text;
                nUser.MobileNumber = txtBoxCepNo.Text;
                kayitliKullaniciList.Add(nUser);

                //button tag=user
                var seats = pnlSeats.Controls.OfType <Button>();
                foreach (Button b in seats)
                {
                    foreach (string ss in selectedSeatList)
                    {
                        if (ss == b.Text)
                        {
                            b.Tag       = nUser;
                            b.BackColor = Color.Red;
                        }
                    }
                }

                //create ticket
                Ticket nTicket = new Ticket();
                nTicket.UserBought = nUser;
                List <Seat> alinanSeats = new List <Seat>();
                foreach (string ss in selectedSeatList)
                {
                    Seat nS = new Seat();
                    nS.SeatNumber = int.Parse(ss);
                    nS.Taken      = true;
                    nS.Details    = "Alındı";
                    nS.Price      = 10m;
                    alinanSeats.Add(nS);
                }
                nTicket.MySeats = alinanSeats;
                alinanBiletlerList.Add(nTicket);

                //send an email
                //SendMailConfirmation(nTicket);

                MessageBox.Show("Your ticket is successfully created.");
                Temizle();
            }
            else //Seat Not Empty -Error
            {
                MessageBox.Show("Eklediğiniz koltuk müsait değildir! Lütfen başka koltuk deneyiniz.");
            }
        }
        private Ticket FindTicket(uint160 contractAddress, Seat seat)
        {
            var tickets = RetrieveTickets(contractAddress);

            return(tickets.FirstOrDefault(ticket => ticket.Seat.Equals(seat)));
        }
        /// <summary>
        /// Handles PayOrder button event and open PrintView in wizard
        /// </summary>
        private void OnPayOrder()
        {
            BlankStatus = String.Empty;
            // if View called from orders
            if (Customer.Order.Seats == null)
            {
                Customer.Order.Seats = new List <Seat>();
                foreach (Ticket t in Tickets)
                {
                    Seat seat = new Seat()
                    {
                        Id = t.Id
                    };
                    Customer.Order.Seats.Add(seat);
                }
            }

            Customer.Order.PaymentType =
                (PaymentType)Enum.Parse(typeof(PaymentType), SelectedPaymentType.Key.ToString(), true);

            _worker         = new BackgroundWorker();
            _worker.DoWork += delegate
            {
                WizardProgressVisibility = Visibility.Visible;

                Customer.Order = Access.ConfirmPayment(Customer.Order);

                if (Customer.Order != null && Customer.Order.Status == ItemStatus.Sold)
                {
                    Blank[] blanks = Access.GetBlanks(0, Customer.Order.ItemsCount, ItemStatus.OnSale);

                    if (blanks != null)
                    {
                        if (blanks.Length != Customer.Order.ItemsCount)
                        {
                            BlankStatus = "Количество бланков недостаточно для печати заказа";
                        }
                    }
                    else
                    {
                        BlankStatus = "У вас отсутствуют бланки";
                    }

                    for (int i = 0; i < Customer.Order.Seats.Count; i++)
                    {
                        Seat seat = Customer.Order.Seats[i];
                        Spot spot = SelectedSpots.FirstOrDefault(x => x.Id == seat.Id);
                        if (spot != null)
                        {
                            spot.Status = seat.Status;
                            //spot.Result = seat.Result;
                            spot.ReserveDate = seat.ReserveDate;
                            if (blanks != null && blanks.Length > i)
                            {
                                spot.Blank = blanks[i];
                            }
                        }
                    }

                    //PersistSelectedSpots(Customer.Order.Seats);
                    StatusText          =
                        OperationResult =
                            String.Format("Заказ № {0} оплачен. Сумма заказа: {1}", Customer.Order.Id,
                                          OrderPrice.ToString("C"));

                    if (_wizardWindow != null)
                    {
                        WizardTitle   = "Печать заказа";
                        ContentWindow = new PrintViewModel(Instance);
                    }

                    _wisardStep = WisardStep.OrderPaid;

                    DisplayTickets();
                }
                else
                {
                    Customer.Order      = new Order(); // Just not to be null
                    StatusText          =
                        OperationResult = String.Format("Произошла ошибка. Заказ № {0} не оплачен", Customer.Order.Id);
                }
            };
            _worker.RunWorkerCompleted += delegate
            {
                WizardProgressVisibility = Visibility.Collapsed;
            };
            _worker.RunWorkerAsync();
        }
        public async Task <CreateAuditoriumResultModel> CreateAuditorium(AuditoriumDomainModel domainModel, int numberOfRows, int numberOfSeats)
        {
            var cinema = await _cinemasRepository.GetByIdAsync(domainModel.CinemaId);

            if (cinema == null)
            {
                return(new CreateAuditoriumResultModel
                {
                    IsSuccessful = false,
                    ErrorMessage = Messages.AUDITORIUM_INVALID_CINEMAID
                });
            }

            var auditorium = await _auditoriumsRepository.GetByAuditName(domainModel.Name, domainModel.CinemaId);

            var sameAuditoriumName = auditorium.ToList();

            if (sameAuditoriumName != null && sameAuditoriumName.Count > 0)
            {
                return(new CreateAuditoriumResultModel
                {
                    IsSuccessful = false,
                    ErrorMessage = Messages.AUDITORIUM_SAME_NAME
                });
            }

            Auditorium newAuditorium = new Auditorium
            {
                AuditName = domainModel.Name,
                CinemaId  = domainModel.CinemaId,
            };

            newAuditorium.Seats = new List <Seat>();

            for (int i = 1; i <= numberOfRows; i++)
            {
                for (int j = 1; j <= numberOfSeats; j++)
                {
                    Seat newSeat = new Seat()
                    {
                        Row    = i,
                        Number = j
                    };

                    newAuditorium.Seats.Add(newSeat);
                }
            }

            Auditorium insertedAuditorium = _auditoriumsRepository.Insert(newAuditorium);

            if (insertedAuditorium == null)
            {
                return(new CreateAuditoriumResultModel
                {
                    IsSuccessful = false,
                    ErrorMessage = Messages.AUDITORIUM_CREATION_ERROR
                });
            }

            _auditoriumsRepository.Save();

            CreateAuditoriumResultModel resultModel = new CreateAuditoriumResultModel
            {
                IsSuccessful = true,
                ErrorMessage = null,
                Auditorium   = new AuditoriumDomainModel
                {
                    Id        = insertedAuditorium.Id,
                    Name      = insertedAuditorium.AuditName,
                    CinemaId  = insertedAuditorium.CinemaId,
                    SeatsList = new List <SeatDomainModel>()
                }
            };

            foreach (var item in insertedAuditorium.Seats)
            {
                resultModel.Auditorium.SeatsList.Add(new SeatDomainModel
                {
                    AuditoriumId = insertedAuditorium.Id,
                    Id           = item.Id,
                    Number       = item.Number,
                    Row          = item.Row
                });
            }

            return(resultModel);
        }
示例#44
0
 /// <summary>
 /// This function gets the player sitting/trying to enter this vehicle.
 /// </summary>
 public Player GetOccupant(Seat seat = Seat.FrontLeft)
 {
     return(ElementManager.Instance.GetElement <Player>(MtaShared.GetVehicleOccupant(element, (int)seat)));
 }
 public OverTwentyOneEvent(Seat seat)
 {
     Seat = seat;
 }
        public Seat Insert(Seat obj)
        {
            var data = _cinemaContext.Seats.Add(obj).Entity;

            return(data);
        }
示例#47
0
 public PassengerView(string name, Seat chosenSeat)
 {
     this.Name = name;
     this.ChosenSeat = chosenSeat;
 }
示例#48
0
 /// <summary>
 /// Get highest total score for a seat and check for bust
 /// </summary>
 /// <param name="seat"></param>
 /// <param name="seatHighestTotalScore"></param>
 /// <returns>true for bust</returns>
 private bool GetHighestTotalScoreAndCheckBust(Seat seat, out int seatHighestTotalScore)
 {
     seatHighestTotalScore = 0;
     return(seat.GetHighestTotalScore(out seatHighestTotalScore));
 }
示例#49
0
 void LeaveTable()
 {
     UnsubscribeToMessages(_table);
      _table.Quit(this);
      //Debug.Print("SCP at Seat {0} quit the table", _mySeat);
      _table = null;
      _mySeat = Seat.None;
 }
示例#50
0
        public static Station InitalizationData()
        {
            List <Train>     TrainList     = new List <Train>();
            List <Passanger> PassangerList = new List <Passanger>();
            Station          station       = new Station(TrainList, PassangerList);

            SerailizationAndDeserealization ser = new SerailizationAndDeserealization();
            string configRoutesAndDates         = Environment.GetEnvironmentVariable("RoutesAndDates");
            string configRoutesAndPrices        = Environment.GetEnvironmentVariable("RoutesAndPrices");
            string configWithSerialize          = Environment.GetEnvironmentVariable("WithSerialize");

            if (configWithSerialize == "False")
            {
                Deb.Print("Start without serialization");

                List <Dictionary <string, DateTime> > RoutesAndDates  = ser.DeserializeListRoutesAndDates(configRoutesAndDates);
                List <Dictionary <string, int> >      RoutesAndPrices = ser.DeserializeListRoutesAndPrices(configRoutesAndPrices);

                var DatesAndPrices = RoutesAndDates.Zip(RoutesAndPrices, (n, w) => new { Routes = n, Prices = w });

                foreach (var rp in DatesAndPrices)
                {
                    station.AddTrain(rp.Routes.Keys.First(), rp.Routes.Keys.Last(), rp.Routes, rp.Prices, new List <Van>());
                }
            }
            else
            {
                Deb.Print("Start with serialization");

                Dictionary <string, int> RouteAndPriceKievChernigiv = new Dictionary <string, int>
                {
                    { "Kiev", 0 },
                    { "Kozelets", 30 },
                    { "Desna", 60 },
                    { "Chernigiv", 100 }
                };

                Dictionary <string, int> RouteAndPriceKievLugansk = new Dictionary <string, int>
                {
                    { "Kiev", 0 },
                    { "Kozelets", 30 },
                    { "Charkiv", 45 },
                    { "Zhitomir", 75 },
                    { "Lugansk", 130 }
                };

                Dictionary <string, int> RouteAndPriceLvivKiev = new Dictionary <string, int>
                {
                    { "Lviv", 0 },
                    { "Gorodishe", 90 },
                    { "Donetsk", 145 },
                    { "Pomoshna", 275 },
                    { "Kiev", 330 }
                };

                Dictionary <string, DateTime> RouteAndDateKievChernigiv = new Dictionary <string, DateTime>
                {
                    { "Kiev", DateTime.Now },
                    { "Kozelets", DateTime.Now + new TimeSpan(0, 3, 0, 0) },
                    { "Desna", DateTime.Now + new TimeSpan(0, 4, 0, 0) },
                    { "Chernigiv", DateTime.Now + new TimeSpan(1, 0, 0, 0) }
                };

                Dictionary <string, DateTime> RouteAndDateKievLugansk = new Dictionary <string, DateTime>
                {
                    { "Kiev", DateTime.Now },
                    { "Kozelets", DateTime.Now + new TimeSpan(0, 3, 0, 0) },
                    { "Charkiv", DateTime.Now + new TimeSpan(1, 0, 0, 0) },
                    { "Zhitomir", DateTime.Now + new TimeSpan(1, 5, 0, 0) },
                    { "Lugansk", DateTime.Now + new TimeSpan(1, 13, 0, 0) }
                };

                Dictionary <string, DateTime> RouteAndDateLvivKiev = new Dictionary <string, DateTime>
                {
                    { "Lviv", DateTime.Now },
                    { "Gorodishe", DateTime.Now + new TimeSpan(0, 3, 0, 0) },
                    { "Donetsk", DateTime.Now + new TimeSpan(0, 8, 0, 0) },
                    { "Pomoshna", DateTime.Now + new TimeSpan(0, 16, 0, 0) },
                    { "Kiev", DateTime.Now + new TimeSpan(1, 3, 0, 0) }
                };

                List <Dictionary <string, DateTime> > RoutesAndDates = new List <Dictionary <string, DateTime> >
                {
                    { RouteAndDateKievChernigiv },
                    { RouteAndDateKievLugansk },
                    { RouteAndDateLvivKiev }
                };

                List <Dictionary <string, int> > RoutesAndPrices = new List <Dictionary <string, int> >
                {
                    { RouteAndPriceKievChernigiv },
                    { RouteAndPriceKievLugansk },
                    { RouteAndPriceLvivKiev }
                };

                ser.SerializeListRoutesAndDates("RoutesAndDates.json", RoutesAndDates);
                ser.SerializeListRoutesAndPrices("RoutesAndPrices.json", RoutesAndPrices);

                ser.SerializeRouteAndPrice("RouteAndPriceKievChernigiv.json", RouteAndPriceKievChernigiv);
                ser.SerializeRouteAndPrice("RouteAndPriceKievLugansk.json", RouteAndPriceKievLugansk);
                ser.SerializeRouteAndPrice("RouteAndPriceLvivKiev.json", RouteAndPriceLvivKiev);

                ser.SerializeRouteAndDate("RouteAndDateKievChernigiv.json", RouteAndDateKievChernigiv);
                ser.SerializeRouteAndDate("RouteAndDateKievLugansk.json", RouteAndDateKievLugansk);
                ser.SerializeRouteAndDate("RouteAndDateLvivKiev.json", RouteAndDateLvivKiev);

                station.AddTrain("Kiev", "Chernigiv", RouteAndDateKievChernigiv, RouteAndPriceKievChernigiv, new List <Van>());
                station.AddTrain("Kiev", "Lugansk", RouteAndDateKievLugansk, RouteAndPriceKievLugansk, new List <Van>());
                station.AddTrain("Lviv", "Kiev", RouteAndDateLvivKiev, RouteAndPriceLvivKiev, new List <Van>());
            }

            foreach (Train train in station.TrainList)
            {
                train.CreateVansForTrain(10, "Plackart");
                train.CreateVansForTrain(2, "Cupe");
                foreach (Van van in train.VanList)
                {
                    van.CreateSeatForVan(3, "Main");
                    van.CreateSeatForVan(3, "Side");
                }
            }

            Van.AddClassAndPrice("Plackart", 0);
            Van.AddClassAndPrice("Cupe", 20);

            Seat.AddTypeAndPrice("Main", 0);
            Seat.AddTypeAndPrice("Side", 0);

            return(station);
        }
示例#51
0
 /// <summary>
 /// 角色初始化。
 /// </summary>
 public void Init(Seat seat)
 {
     this.seat     = seat;
     nameText.text = seat.role.displayName;
 }
示例#52
0
 public IActionResult List([FromBody] Seat seat)
 {
     return(Json(db.GetSeat(seat.Id)));
 }
示例#53
0
        private void Service_PlaceSeats(object sender, GetBookedSeatsCompletedEventArgs e)
        {
            SingletonQuery.QueryClient.GetBookedSeatsCompleted -= this.Service_PlaceSeats;

            if (e.Error == null)
            {
                Seat[,] seats = new Seat[ROWS, POSITIONS];
                ObservableCollection<Seat> gotBookedSeats = e.Result;

                foreach (var gotBookedSeat in gotBookedSeats)
                {
                    seats[gotBookedSeat.Row, gotBookedSeat.Position] = gotBookedSeat;
                }

                for (int row = 1; row < ROWS; row++)
                {
                    for (int position = 1; position < POSITIONS; position++)
                    {
                        int currentRow = 11 - row;

                        Button btnSeat = new Button();
                        btnSeat.Margin = new Thickness(-10, -10, -10, -10);
                        btnSeat.Tag = string.Format("row{0}position{1}", row, position);
                        btnSeat.Width = 90;
                        btnSeat.Height = 90;
                        Grid.SetRow(btnSeat, currentRow);
                        Grid.SetColumn(btnSeat, position);
                        btnSeat.BorderBrush = null;

                        if (seats[row, position] == null)
                        {
                            btnSeat.Background = freeSeat.Background;

                            btnSeat.Click += this.btnSeat_Click;
                        }
                        else
                        {
                            btnSeat.Background = bookedSeat.Background;
                        }

                        this.seatsContainer.Children.Add(btnSeat);
                    }
                }

                for (int index = 1; index < ROWS; index++)
                {
                    TextBlock lblRow = new TextBlock();
                    lblRow.Foreground = new SolidColorBrush(Colors.Yellow);
                    lblRow.HorizontalAlignment = HorizontalAlignment.Center;
                    lblRow.VerticalAlignment = VerticalAlignment.Center;
                    lblRow.Text = index.ToString();
                    Grid.SetRow(lblRow, ROWS - index);
                    Grid.SetColumn(lblRow, 0);
                    this.seatsContainer.Children.Add(lblRow);

                    TextBlock lblPosition = new TextBlock();
                    lblPosition.Foreground = new SolidColorBrush(Colors.Yellow);
                    lblPosition.HorizontalAlignment = HorizontalAlignment.Center;
                    lblPosition.Text = index.ToString();
                    Grid.SetRow(lblPosition, 0);
                    Grid.SetColumn(lblPosition, index);
                    this.seatsContainer.Children.Add(lblPosition);
                }

                TextBlock caption = new TextBlock();
                caption.Foreground = new SolidColorBrush(Colors.Yellow);
                caption.Text = "Cols Rows";
                caption.FontSize = 10;
                caption.TextWrapping = TextWrapping.Wrap;

                Grid.SetRow(caption, 0);
                Grid.SetColumn(caption, 0);

                this.seatsContainer.Children.Add(caption);
            }
        }
示例#54
0
 public IActionResult Update([FromBody] Seat seat)
 {
     return(Ok(db.UpdateSeat(seat.Id, seat.Row, seat.Number, seat.AuditoriumId)));
 }
示例#55
0
文件: Trick.cs 项目: rsarwas/BridgeIt
        public void AddCard(Card card, Seat player)
        {
            if (Done)
                throw new Exception("Trick is done, cannot add more cards.");
            if (_cards.Contains(card))
                throw new Exception("Card is already in the trick.");

            //FIXME - add check for player has already played
            //FIXME - add check for card is added by the right player (clockwise around table)

            _cards.Add(card);
            _players.Add(player);

            _winner = GetWinner();
            if (Suit == Suit.None)
                Suit = card.Suit;
        }
示例#56
0
 public IActionResult Delete([FromBody] Seat seat)
 {
     return(Ok(db.DeleteSeat(seat.Id)));
 }
示例#57
0
        public ActionResult Seating(int id, string seating)
        {
            // Get Event
            var theEvent = _repo
                .Events
                .SingleOrDefault(e => e.EventID == id);

            if (theEvent == null)
                return RedirectToAction("Events");

            var rows = seating.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            var seats = new List<Seat>();
            var seatCodes = new List<string>();

            for (int i = 0; i < rows.Count(); i++)
            {
                var row = rows[i].ToLower();

                for (int j = 0; j < row.Length; j++)
                {
                    var seatChar = row[j];

                    var seat = new Seat { Row = i, Column = j, EventID = theEvent.EventID };
                    seats.Add(seat);

                    switch (seatChar)
                    {
                        case 'x':
                            seat.Code = CodeHelper.GenerateUniqueSeatCode(seatCodes);
                            break;
                        case '.':
                            break;
                        default:
                            break;
                    }
                }
            }

            // Delete the old seating plan
            _repo
                .Sats
                .DeleteAllOnSubmit(theEvent
                    .Seats
                    .SelectMany(s => s.Sats));
            _repo
                .Seats
                .DeleteAllOnSubmit(theEvent.Seats);

            // Insert the new seating plan
            _repo
                .Seats
                .InsertAllOnSubmit(seats);

            _repo.SubmitChanges();

            return RedirectToAction("Seating", new { id = theEvent.EventID });
        }
示例#58
0
        public async Task <bool> CreateFlight(Flight flight)
        {
            try
            {
                AirlineCompany company = (await _context.AirlineCompany.ToListAsync()).FirstOrDefault(x => x.Id == flight.AvioCompany.Id);

                PlaneType planeType = (await _context.PlaneType.ToListAsync()).FirstOrDefault(x => x.Id == flight.SeatConfiguration.PlaneType.Id);


                List <Destination> destinations = new List <Destination>();   //ovo cemo dodati kao polje, to popunjavamo
                Destination        destination;
                foreach (var d in flight.Destinations)
                {
                    destination = new Destination()
                    {
                        Address     = d.Address,
                        City        = d.City,
                        AirportName = d.AirportName,
                        Country     = d.Country
                    };

                    await _context.Destination.AddAsync(destination);

                    destinations.Add(destination);
                }

                List <Row> allRows = new List <Row>();
                Row        r;
                //List<Seat> seatsInRow = new List<Seat>();
                Seat s;
                for (var rowIndex = 0; rowIndex < flight.SeatConfiguration.Seats.Count; rowIndex++)
                {
                    r = new Row()
                    {
                        RowNo = rowIndex,
                        Seats = new List <Seat>()
                    };
                    foreach (var seat in flight.SeatConfiguration.Seats[rowIndex].Seats)
                    {
                        s = new Seat()
                        {
                            ForFastReservation = seat.ForFastReservation,
                            PassengerEmail     = seat.PassengerEmail,
                            SeatNo             = seat.SeatNo,
                            SeatStatus         = seat.SeatStatus,
                        };

                        await _context.Seat.AddAsync(s);

                        await _context.SaveChangesAsync();

                        r.Seats.Add(s);
                    }

                    await _context.Row.AddAsync(r);

                    allRows.Add(r);
                }
                //cuvam sve prethodne promene
                //await _context.SaveChangesAsync();


                SeatConfiguration seatConfiguration = new SeatConfiguration()
                {
                    PlaneType = planeType,
                    Seats     = allRows
                };

                var f = new Flight()
                {
                    AvioCompany       = company,
                    StartDate         = flight.StartDate,
                    ArrivingDate      = flight.ArrivingDate,
                    StartTime         = flight.StartTime,
                    ArrivingTime      = flight.ArrivingTime,
                    EstimationTime    = flight.EstimationTime,
                    Distance          = flight.Distance,
                    Discount          = flight.Discount,
                    SeatConfiguration = seatConfiguration,
                    Destinations      = destinations,
                    OtherServices     = flight.OtherServices,
                    Price             = flight.Price,
                    Luggage           = flight.Luggage,
                };


                _context.Flight.Add(f);
                await _context.SaveChangesAsync();

                return(true);
            }catch (Exception e)
            {
                return(false);
            }
        }
示例#59
0
 /// <summary>
 /// Warp this ped into a vehicle, specifying a seat
 /// </summary>
 public bool WarpIntoVehicle(SharedVehicle vehicle, Seat seat)
 {
     return(MtaShared.WarpPedIntoVehicle(element, vehicle.MTAElement, (int)seat));
 }
示例#60
0
        public static string ImportHallSeats(CinemaContext context, string jsonString)
        {
            var hallsDtos = JsonConvert.DeserializeObject <ImportHallDto[]>(jsonString);

            List <Hall>   hallsToAdd = new List <Hall>();
            StringBuilder sb         = new StringBuilder();

            foreach (var hallDto in hallsDtos)
            {
                if (!IsValid(hallDto))
                {
                    sb.AppendLine(ErrorMessage);
                    continue;
                }

                Hall hall = Mapper.Map <Hall>(hallDto);

                if (!IsValid(hall))
                {
                    sb.AppendLine(ErrorMessage);
                    continue;
                }

                hallsToAdd.Add(hall);

                for (int i = 0; i < hallDto.SeatsCount; i++)
                {
                    Seat seat = new Seat();
                    seat.HallId = hall.Id;

                    hall.Seats.Add(seat);
                }

                string projectionType;

                if (hallDto.Is3D && hallDto.Is4Dx)
                {
                    projectionType = "3D/4Dx";
                }
                else if (!hallDto.Is3D && !hallDto.Is4Dx)
                {
                    projectionType = "Normal";
                }
                else if (!hallDto.Is3D && hallDto.Is4Dx)
                {
                    projectionType = "4Dx";
                }
                else
                {
                    projectionType = "3D";
                }

                sb.AppendLine(string.Format(SuccessfulImportHallSeat,
                                            hall.Name,
                                            projectionType,
                                            hall.Seats.Count));
            }


            context.Halls.AddRange(hallsToAdd);
            context.SaveChanges();

            return(sb.ToString().TrimEnd());
        }