Exemple #1
0
            public void Execute()
            {
                PrintAllUsersCommand printAllUsers = new PrintAllUsersCommand();

                printAllUsers.Execute();

                System.Console.WriteLine();
                System.Console.WriteLine("Select the id of the user: ");
                int idUser = Convert.ToInt32(System.Console.ReadLine());

                foreach (UserGroup userGroup in unitOfWork.UserGroupRepository.GetAllBy(ug => ug.UserId == idUser))
                {
                    System.Console.WriteLine(unitOfWork.GroupRepository.FindBy(group => group.Id == userGroup.GroupId));
                }
            }
Exemple #2
0
            public void Execute()
            {
                PrintAllGroupsCommand printAllGroups = new PrintAllGroupsCommand();

                printAllGroups.Execute();

                PrintAllUsersCommand printAllUsers = new PrintAllUsersCommand();

                System.Console.WriteLine("Select the id of the group you want to add users");
                int idGrupa = Convert.ToInt32(System.Console.ReadLine());

                Group group = unitOfWork.GroupRepository.FindBy(g => g.Id == idGrupa);

                printAllUsers.Execute();
                System.Console.WriteLine();
                System.Console.WriteLine("Select the id of the users you want to add in the selected group and when you are done enter 0");

                List <User> selectedUsers = new List <User>();

                int idUser;

                do
                {
                    idUser = Convert.ToInt32(System.Console.ReadLine());
                    User user = unitOfWork.UserRepository.FindBy(u => u.Id == idUser);
                    if (!selectedUsers.Contains(user) && idUser != 0)
                    {
                        selectedUsers.Add(user);
                    }
                } while (idUser != 0);


                for (int index = 0; index < selectedUsers.Count; index++)
                {
                    UserGroup userGroup = new UserGroup()
                    {
                        UserId = selectedUsers[index].Id, GroupId = group.Id, Group = group, User = selectedUsers[0]
                    };
                    selectedUsers[index].UserGroups.Add(userGroup);
                    group.UserGroups.Add(userGroup);
                    unitOfWork.UserGroupRepository.Add(userGroup);
                }

                unitOfWork.save();
            }
Exemple #3
0
            public void Execute()
            {
                PrintAllUsersCommand printAllUsers = new PrintAllUsersCommand();

                printAllUsers.Execute();
                System.Console.WriteLine();

                System.Console.WriteLine("Select the username of the user you want to update: ");
                String username = System.Console.ReadLine();

                User user = unitOfWork.UserRepository.FindBy(u => u.Username == username);

                System.Console.WriteLine("Change the username: ");
                String newUername = System.Console.ReadLine();

                user.Username = newUername;
                unitOfWork.UserRepository.Update(user);
                unitOfWork.save();
            }
Exemple #4
0
            public void Execute()
            {
                PrintAllGroupsCommand printAllGroups = new PrintAllGroupsCommand();
                PrintAllUsersCommand  printAllUsers  = new PrintAllUsersCommand();

                printAllGroups.Execute();

                System.Console.WriteLine();

                System.Console.WriteLine("Select the id of the group you want to add an admin: ");
                int idGrupa = Convert.ToInt32(System.Console.ReadLine());

                Group group = unitOfWork.GroupRepository.FindBy(g => g.Id == idGrupa);

                //inner join pe idGrupa
                foreach (UserGroup userGroup in unitOfWork.UserGroupRepository.GetAll())
                {
                    if (userGroup.GroupId == idGrupa)
                    {
                        System.Console.WriteLine(unitOfWork.UserRepository.FindBy(u => u.Id == userGroup.UserId));
                    }
                }


                System.Console.WriteLine("Select the id of the user from the group you want to add as admin: ");
                int idUser = Convert.ToInt32(System.Console.ReadLine());

                User user = unitOfWork.UserRepository.FindBy(u => u.Id == idUser);

                GroupAdmin groupAdmin = new GroupAdmin()
                {
                    GroupAdminForeignKey = user.Id, Name = user.Fullname, Group = group
                };

                unitOfWork.GroupAdminRepository.Add(groupAdmin);
                group.Admin = groupAdmin;
                unitOfWork.save();
            }
Exemple #5
0
            public void Execute()
            {
                PrinAllInterestsCommand prinAllInterestsCommand = new PrinAllInterestsCommand();
                PrintAllUsersCommand    printAllUsers           = new PrintAllUsersCommand();

                printAllUsers.Execute();

                System.Console.WriteLine("Select the id of the user you want to add an interest: ");
                int idUser = Convert.ToInt32(System.Console.ReadLine());

                prinAllInterestsCommand.Execute();
                System.Console.WriteLine("Select the id of the interst you want to add: ");
                int idInterest = Convert.ToInt32(System.Console.ReadLine());


                User     user     = unitOfWork.UserRepository.FindBy(u => u.Id == idUser);
                Interest interest = unitOfWork.InterestRepository.FindBy(inter => inter.Id == idInterest);

                user.Interests.Add(interest);
                interest.User = user;

                unitOfWork.save();
            }