private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var s = new Seat();
            s.SeatName = "<Seat>";
            s.Color = Utils.ColorToInt(Colors.LawnGreen);

            Seats.Add(s);
            PublicBoardCtx.Get().AddToSeat(s);
        }
Exemple #2
0
        public LoginName(Seat selectedSeat)
        {
            InitializeComponent();

            DataContext = this;

            //SkinManager.ChangeSkin("GreenSkin.xaml", this.Assets);
            SkinManager.ChangeSkin("Blue2Skin.xaml", this.Resources);

            if (selectedSeat != null && selectedSeat.Person != null)
            {
                var pers = selectedSeat.Person.LastOrDefault();
                if (pers != null)
                {
                    EnteredName = pers.Name;
                    tbxName.Text = pers.Name;
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Seat EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSeat(Seat seat)
 {
     base.AddObject("Seat", seat);
 }
Exemple #4
0
 /// <summary>
 /// Create a new Seat object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="color">Initial value of the Color property.</param>
 /// <param name="seatName">Initial value of the SeatName property.</param>
 public static Seat CreateSeat(global::System.Int32 id, global::System.Int32 color, global::System.String seatName)
 {
     Seat seat = new Seat();
     seat.Id = id;
     seat.Color = color;
     seat.SeatName = seatName;
     return seat;
 }
 private void lstBxSeats_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     SelectedSeat = e.AddedItems[0] as Seat;
     Close();
 }
Exemple #6
0
        //static bool NameUnique(string Name, Session session)
        //{
        //    var sessionId = session.Id;
        //    DbCtx.DropContext();
        //    var outrunnerPerson = DbCtx.Get().Person.FirstOrDefault(p0=>p0.Name==Name && p0.Session != null && p0.Session.Id == sessionId);
        //    return outrunnerPerson == null;
        //}

        private static bool placeAlreadyBusy(Session session, Seat seat)
        {
            var sessionId = session.Id;
            var seatId = seat.Id;
            DbCtx.DropContext();
            var outrunnerPerson = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Online &&
                                                                          p0.Session != null &&
                                                                          p0.Session.Id == sessionId &&
                                                                          p0.Seat != null && p0.Seat.Id == seatId);

            //only if outrunner person exists and online, the place is busy
            return (outrunnerPerson != null);
        }
Exemple #7
0
        //if given seat was not used in current session, and user takes the seat, new user is created in DB.
        //if user takes seat that was used in this session, then no new user is created. instead, the user 
        //is recognized as the same user who took the seat in current session, though during second login user 
        //enters name again (effectively changing name)
        private static Person RegisterOrLogin(string name, Discussion discussion, Session session, Seat seat)
        {
            //was the seat taken by some user? 
            var sessionId = session.Id;
            var seatId = seat.Id;
            DbCtx.DropContext();
            var outrunnerPerson =
                DbCtx.Get().Person.FirstOrDefault(p0 => p0.Session != null && p0.Session.Id == sessionId &&
                                                        p0.Seat != null && p0.Seat.Id == seatId);

            //the user already took the place, just change name
            if (outrunnerPerson != null)
            {
                outrunnerPerson.Name = name;

                //do we need general side ? 
                var ctx = DbCtx.Get();
                var previousGenSide = ctx.GeneralSide.FirstOrDefault(gs0 => gs0.Discussion.Id == discussion.Id &&
                                                                            gs0.Person.Id == outrunnerPerson.Id);
                if (previousGenSide == null)
                {
                    //the person takes part in this discussion first time, create general 
                    //side of the person in this discussion
                    var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussion.Id);
                    outrunnerPerson.GeneralSide.Add(
                        CreateGeneralSide(
                            outrunnerPerson,
                            disc,
                            (int) SideCode.Neutral
                            )
                        );

                    //assign person to all topics of selected discussion
                    foreach (var topic in disc.Topic)
                        outrunnerPerson.Topic.Add(topic);
                }

                DbCtx.Get().SaveChanges();

                return outrunnerPerson;
            }
            else
            {
                //seat was not used in this session, create new user
                var ctx = DbCtx.Get();
                var p = new Person();
                p.Name = name;
                p.Session = ctx.Session.FirstOrDefault(s0 => s0.Id == session.Id);
                p.Seat = ctx.Seat.FirstOrDefault(s0 => s0.Id == seat.Id);

                var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussion.Id);
                p.GeneralSide.Add(CreateGeneralSide(p, disc, (int) SideCode.Neutral));

                //person inherits color of seat
                p.Color = p.Seat.Color;

                p.Email = "no-email";

                //assign person to all topics of selected discussion
                foreach (var topic in disc.Topic)
                    p.Topic.Add(topic);

                ctx.AddToPerson(p);
                DbCtx.Get().SaveChanges();
                return p;
            }
        }