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)); } }
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(); }
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(); }
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(); }