public ActionResult Create(Group group) { if (ModelState.IsValid) { _Storage.CreateGroup(group); return(RedirectToAction("Index")); } else { return(View(group)); } }
public static void GroupOfStudents(string groupName, IEnumerable <User> students, IUserStorage userStorage) { Group demoGroup = new Group { Name = groupName }; if (!userStorage.GetGroups().Select(g => g.Name).Contains(demoGroup.Name)) { userStorage.CreateGroup(demoGroup); } else { demoGroup.Id = userStorage.GetGroups().FirstOrDefault(g => g.Name == demoGroup.Name).Id; } foreach (var stud in students.Select(s => s).Where(s => !userStorage.GetUsers().Select(u => u.Username).Contains(s.Username))) { userStorage.CreateUser(stud); userStorage.AddUserToRole(Role.Student, stud); userStorage.AddUserToGroup(demoGroup, stud); } }
public static void GroupOfStudents(string groupName, IEnumerable<User> students, IUserStorage userStorage) { Group demoGroup = new Group { Name = groupName }; if (!userStorage.GetGroups().Select(g => g.Name).Contains(demoGroup.Name)) { userStorage.CreateGroup(demoGroup); } else { demoGroup.Id = userStorage.GetGroups().FirstOrDefault(g => g.Name == demoGroup.Name).Id; } foreach (var stud in students.Select(s => s).Where(s => !userStorage.GetUsers().Select(u => u.Username).Contains(s.Username))) { userStorage.CreateUser(stud); userStorage.AddUserToRole(Role.Student, stud); userStorage.AddUserToGroup(demoGroup, stud); } }