예제 #1
0
        protected void AddUser(object sender, EventArgs e)
        {
            if(!IsValidGroup()) return;

            if (Group == null)
            {
                Group = new Group();
                SetGroupSettings();
                Group.Insert(Group.Parent);
            }
            else
            {
                SetGroupSettings();
                Group.Update();
            }

            Details payingUser = new DetailsCollection((List<Details>)Session[Local.CurrentMembers.ToString()])
                [groupMemberList.SelectedIndex];

            MembershipUser loggedInUser = new UtilityFunctions().GetThisUser();

            if (loggedInUser == null ||
                !loggedInUser.IsOnline ||
                loggedInUser.ProviderUserKey != payingUser.User.ProviderUserKey)
            {
                // Enter clicks button.
                this.Page.Form.DefaultButton = payButton.UniqueID;

                payLogin.Visible = true;

                // Databind paying user name in password confirmation screen.
                LoadGroupMembers(
                    payingUserSelection,
                    new DetailsCollection((List<Details>)Session[Local.CurrentMembers.ToString()]).GetUsers());
                payingUserSelection.SelectedIndex = groupMemberList.SelectedIndex;

                Session[Local.Group.ToString()] = Group;

                return;
            }

            InsertGroupMember(payingUser);
        }
예제 #2
0
        public GroupMember(DataRow row, Group parent)
        {
            Parent = parent;

            Extract(row);
        }
예제 #3
0
        protected void Join(object sender, EventArgs e)
        {
            // Show group area;
            // TODO: ^^
            if (CurrentUser == null)
            {
                ((MasterPageMobi)Master).OpenConfirmWindow(
                    WindowType.Error,
                    ErrorMessage.LoginGroup,
                    true);

                return;
            }

            int flightNo = int.Parse(((Button)sender).CommandArgument);

            Group = new Group();
            Group.GroupType = Group.GroupTypeCollection[0];
            Group.Insert(Timetable.Planes.CurrentFlights.Find(x => x.FlightId == flightNo));
            CurrentUser.CreatedGroups.Add(Group);

            flightsRepeater.Visible = false;
            groupsRepeater.Visible = true;

            Session[Local.Group.ToString()] = Group;

            ((MasterPageMobi)Master).ResetAndRefresh();

            ClientScript.RegisterStartupScript(
                typeof(Page),
                "SetGroups",
                "<script type='text/javascript'>SetLastGroup();</script>");
        }
예제 #4
0
        public static void GenerateFlights(int numberOfFlights)
        {
            PlaneCollection planes = Timetable.Planes;
            List<Details> users = PlaneCollection.Users.ToList();

            if(planes.Count == 0)
            {
                GeneratePlanes(7);
            }

            for (int counter = 0; counter < numberOfFlights; counter++)
            {
                Flight flight = new Flight();
                flight.Parent = planes[counter % planes.Count];

                flight.Name = flight.Parent.Name + ": Lift " + (flight.Parent.Flights.Count + 1);
                flight.Capacity = flight.Parent.MaxCapacity;
                flight.FuelConsumed = flight.Parent.FuelAfterPrevFlight;

                if (flight.Parent.Flights.Count != 0 &&
                    flight.Parent.Flights.Last().DepartureTime > DateTime.Now)
                {
                    // If there are flights not departed yet queue next plane 20 mins after.

                    flight.DepartureTime = flight.Parent.Flights.Last().DepartureTime.AddMinutes(20);
                }
                else
                {
                    flight.DepartureTime = DateTime.Now.AddMinutes(20);
                }

                // Insert without db get.
                flight.Insert();

                List<Details> listOfUsers = new List<Details>(users);
                Random rndUser = new Random();

                while (flight.Spaces > 14)
                {
                    Group group = new Group();
                    group.GroupType = Group.GroupTypeCollection[new Random().Next(Group.GroupTypeCollection.Count)];
                    group.StickToFlight = false;
                    group.Created = DateTime.Now;
                    group.Updated = DateTime.Now;

                    group.Insert(flight);

                    for (int userCounter = 0; userCounter < new Random().Next(1, 5); userCounter++)
                    {
                        GroupMember member = new GroupMember(
                            listOfUsers[rndUser.Next(listOfUsers.Count)]);
                        member.KitHire = new Random().Next(2) % 2 == 0;
                        member.Payer = member.UserDetails;

                        group.AddMember(member);
                        listOfUsers.Remove(member.UserDetails);
                    }
                }
            }
        }