public void Execute() { PrintAllGroupsCommand printAllGroups = new PrintAllGroupsCommand(); printAllGroups.Execute(); System.Console.WriteLine("Select the id of the group you want to delete the admin: "); int idGrupa = Convert.ToInt32(System.Console.ReadLine()); System.Console.WriteLine(unitOfWork.GroupAdminRepository.FindBy(grA => grA.Group.Id == idGrupa).ToString()); }
public void Execute() { PrintAllGroupsCommand printAllGroups = new PrintAllGroupsCommand(); printAllGroups.Execute(); System.Console.WriteLine("Select the id of the group you want to delete: "); int id = Convert.ToInt32(System.Console.ReadLine()); Group group = unitOfWork.GroupRepository.FindBy(g => g.Id == id); unitOfWork.GroupRepository.Delete(group); unitOfWork.save(); }
public void Execute() { PrintAllGroupsCommand printAllGroups = new PrintAllGroupsCommand(); printAllGroups.Execute(); System.Console.WriteLine(); System.Console.WriteLine("Select the id of the group: "); int idGrupa = Convert.ToInt32(System.Console.ReadLine()); foreach (UserGroup userGroup in unitOfWork.UserGroupRepository.GetAllBy(ug => ug.GroupId == idGrupa)) { System.Console.WriteLine(unitOfWork.UserRepository.FindBy(user => user.Id == userGroup.UserId)); } }
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() { PrintAllGroupsCommand printAllGroups = new PrintAllGroupsCommand(); printAllGroups.Execute(); System.Console.WriteLine("Select the id of the group you want to update: "); int id = Convert.ToInt32(System.Console.ReadLine()); System.Console.WriteLine("Give the new name to the group: "); String newName = System.Console.ReadLine(); Group group = unitOfWork.GroupRepository.FindBy(g => g.Id == id); group.Name = newName; unitOfWork.GroupRepository.Update(group); unitOfWork.save(); }
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(); }