示例#1
0
文件: Flight.cs 项目: sliplow/Skyline
        public bool OnFlight(GroupMember currentMember)
        {
            if (Groups.Exists(
                x => x.GroupMembers.Exists(
                    y => y.ProviderUserKey == currentMember.ProviderUserKey))) return true;

            return false;
        }
示例#2
0
        private void InsertGroupMember(Details payingUser)
        {
            GroupMember currentMember = new GroupMember(
                (new DetailsCollection((List<Details>)Session[Local.SearchedUsers.ToString()])).Find(
                    userSelected.SelectedValue));

            currentMember.KitHire = kitHire.Checked;
            currentMember.Payer = payingUser;

            if (!Group.Parent.CanJoin)
            {
                ((Site1)Master).OpenConfirmWindow(
                    WindowType.Error,
                    ErrorMessage.FlightFull,
                    false);

                return;
            }

            if (!Group.AddMember(currentMember))
            {
                ((Site1)Master).OpenConfirmWindow(
                    WindowType.Error,
                    ErrorMessage.UserOnFlight,
                    false);

                return;
            }

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

            DataBindings();
            ((Site1)Master).ResetAndRefresh();
        }
示例#3
0
文件: Group.cs 项目: sliplow/Skyline
        public bool AddMember(GroupMember currentMember)
        {
            if (Parent.OnFlight(currentMember)) return false;

            currentMember.Parent = this;
            return currentMember.Insert();
        }
示例#4
0
        private void InsertGroupMember(Details payingUser)
        {
            GroupMember currentMember = new GroupMember(
                (new DetailsCollection((List<Details>)Session[Local.SearchedUsers.ToString()])).Find(
                    userSelected.SelectedValue));

            currentMember.KitHire = kitHire.Checked;
            currentMember.Payer = payingUser;

            if (!Group.Parent.CanJoin)
            {
                ((MasterPageMobi)Master).OpenConfirmWindow(
                    WindowType.Error,
                    ErrorMessage.FlightFull,
                    false);

                return;
            }

            if (!Group.AddMember(currentMember))
            {
                ((MasterPageMobi)Master).OpenConfirmWindow(
                    WindowType.Error,
                    ErrorMessage.UserOnFlight,
                    false);

                return;
            }

            if(Group.GroupMembers.Count == 1)
            {
                // Add the group to a real group collection instead of the temp lists.
                Group.GroupMembers[0].UserDetails.Groups.Add(Group);

                // Remove group from temp list
                Group.GroupMembers[0].UserDetails.CreatedGroups.Remove(Group);
            }

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

            DataBindings();
            ((MasterPageMobi)Master).ResetAndRefresh();
        }
示例#5
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);
                    }
                }
            }
        }