Example #1
0
        public static Dictionary <int, Queue <int> > CreateRooms()
        {
            Dictionary <int, Queue <int> > Rooms = new Dictionary <int, Queue <int> >();

            try
            {
                databaseDataContext db = new databaseDataContext();

                var plans =
                    (from p in db.Plans
                     select p);

                foreach (Plan plan in plans)
                {
                    Queue <int> queue = new Queue <int>();
                    queue.Enqueue(plan.UserId); //master

                    foreach (UserDTO user in UserPlans.JoinedUsers(plan.Id))
                    {
                        queue.Enqueue(user.Id);
                    }

                    Rooms.Add(plan.Id, queue);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(Rooms);
        }
Example #2
0
        public static void ChangeMaster(int planId)
        {
            PlanDTO     plan     = Plans.Read(planId);
            UserPlanDTO userPlan = UserPlans.ReadPlanId(planId);

            UserPlanDTO newUserPlan = new UserPlanDTO()
            {
                UserId = plan.UserId,
                PlanId = plan.Id
            };

            PlanDTO updatePlan = new PlanDTO()
            {
                Id     = planId,
                UserId = userPlan.UserId,
                Name   = plan.Name
            };

            Plans.Update(updatePlan);
            UserPlans.Delete(userPlan.Id);
            UserPlans.Create(newUserPlan);
        }