public void CreateGroup() { var group = new Group() { Deleted = false, Id = 123, Name = "pmi31" }; _Tests.Storage.CreateGroup(group); Assert.AreEqual(group.Name, _Tests.Storage.GetGroup(group.Id).Name); _Tests.Storage.DeleteGroup(group.Id); }
public void DeleteGroupSuccess() { var group = new Group() { Deleted = false, Id = 333, Name = "pma31" }; _Tests.Storage.CreateGroup(group); _Tests.Storage.DeleteGroup(group.Id); Assert.AreEqual(_Tests.Storage.GetGroups().Count(),1 ); }
public void AddUserToGroup(Group group, User user) { var db = GetDbContext(); var groupUser = new GroupUser {GroupRef = group.Id, UserRef = user.Id}; db.GroupUsers.InsertOnSubmit(groupUser); db.SubmitChanges(); }
public void CreateGroup(Group group) { var db = GetDbContext(); group.Deleted = false; db.Groups.InsertOnSubmit(group); db.SubmitChanges(); }
public ActionResult Edit(int id, Group group) { if (ModelState.IsValid && Storage.EditGroup(id, group)) { return RedirectToAction("Index"); } else { return View(group); } }
public ActionResult Create(Group group) { if (ModelState.IsValid && Storage.CreateGroup(group)) { return RedirectToAction("Index"); } else { return View(group); } }
public bool CreateGroup(Group group) { try { db.Groups.InsertOnSubmit(group); db.SubmitChanges(); return true; } catch { return false; } }
public static List<Group> FakeGroupsByThemeIdOrCurriculumId(int selectThemeId) { Group fakeGroup1 = new Group(); fakeGroup1.Id = 1; fakeGroup1.Name = "PMI-31"; Group fakeGroup2 = new Group(); fakeGroup2.Id = 2; fakeGroup2.Name = "PMI-32"; Group fakeGroup3 = new Group(); fakeGroup3.Id = 3; fakeGroup3.Name = "PMI-33"; return new List<Group>() { fakeGroup1, fakeGroup2, fakeGroup3 }; }
public bool EditGroup(int id, Group group) { try { Group oldGroup = GetGroup(id); oldGroup.Name = group.Name; db.SubmitChanges(); return true; } catch { return false; } }
public IEnumerable<User> GetUsersInGroup(Group group) { var db = GetDbContext(); return db.GroupUsers.Where(g => g.GroupRef == group.Id && !g.User.Deleted).Select(g => g.User); }
public IEnumerable<User> GetUsersBySelectedGroup(Group group) { return _LmsService.FindService<IUserService>().GetUsersByGroup(group); }
public IEnumerable<User> GetUsersByGroup(Group group) { return _UserStorage.GetUsersInGroup(group); }
public void GetCurriculumsByGroupId() { List<Curriculum> curriculums = CreateDefaultData(); curriculums.ForEach(item=>_Storage.AddCurriculum(item)); Group group = new Group { Id = 1, Name = "Group1" }; var curriculumAssignments = curriculums.Select(item => new CurriculumAssignment { Curriculum = item, UserGroupRef = group.Id }) .ToList(); curriculumAssignments.ForEach(i => _Storage.AddCurriculumAssignment(i)); Assert.AreEqual(curriculums, _Storage.GetCurriculumsByGroupId(group.Id).ToList()); }
partial void DeleteGroup(Group instance);
public void RemoveUserFromGroup(Group group, User user) { var db = GetDbContext(); var groupUser = db.GroupUsers.Single(g => g.GroupRef == group.Id && g.UserRef == user.Id); db.GroupUsers.DeleteOnSubmit(groupUser); db.SubmitChanges(); }
public void EditGroup(int id, Group group) { using (var db = new UserManagementDBContext()) { var oldGroup = db.Groups.Single(g => g.Id == id && !g.Deleted); oldGroup.Name = group.Name; db.SaveChanges(); } _LmsService.Inform(UserNotifications.GroupEdit, group); }
public void AddUserToGroup(Group group, User user) { using (var db = new UserManagementDBContext()) { db.Users.Attach(user); db.Groups.Attach(group); group.Users.Add(user); db.SaveChanges(); } }
public ActionResult Search(String query) { if (query == "") return RedirectToAction("Index"); query = query + "~"; DateTime datastart = DateTime.Now; Directory directory = FSDirectory.Open(new System.IO.DirectoryInfo(Server.MapPath("~/Data/Index"))); IndexSearcher searcher = new IndexSearcher(directory, true); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29); MultiFieldQueryParser queryParser = new MultiFieldQueryParser( Version.LUCENE_29, new String[] { "Name", "Content", "Curriculum", "User", "Group", "Theme" }, analyzer ); ScoreDoc[] scoreDocs = searcher.Search(queryParser.Parse(query), 100).scoreDocs; Hits hit = searcher.Search(queryParser.Parse(query)); int total = hit.Length(); List<ISearchResult> results = new List<ISearchResult>(); Stopwatch sw = new Stopwatch(); sw.Start(); foreach (ScoreDoc doc in scoreDocs) { ISearchResult result; Document document = searcher.Doc(doc.doc); String type = document.Get("Type").ToLower(); switch (type) { case "node": Node node = new Node(); node.Id = Convert.ToInt32(document.Get("ID")); node.Name = document.Get("Name"); node.CourseId = Convert.ToInt32(document.Get("CourseID")); node.IsFolder = Convert.ToBoolean(document.Get("isFolder")); result = new NodeResult(node, _CourseService.GetCourse(node.CourseId).Name, document.Get("Content"), _CourseService.GetCourse(node.CourseId).Updated.ToString()); break; case "course": Course course = new Course(); course.Id = Convert.ToInt32(document.Get("ID")); course.Name = document.Get("Name"); result = new CourseResult(course,_CourseService.GetCourse(course.Id).Updated.ToString(), _CourseService.GetCourse(course.Id).Owner); break; case "curriculum": Curriculum curriculum = new Curriculum(); curriculum.Id = Convert.ToInt32(document.Get("ID")); curriculum.Name = document.Get("Curriculum"); result = new CurriculumResult(curriculum, _CurriculmService.GetCurriculum(curriculum.Id).Updated.ToString()); break; case "user": User user = new User(); user.Id = Guid.Parse(document.Get("ID")); user.Name = document.Get("User"); /*user.RoleId = Convert.ToInt32(document.Get("RoleId"));*/ result = new UserResult(user, user.RolesLine); break; case "group": Group group = new Group(); group.Id = int.Parse(document.Get("ID")); group.Name = document.Get("Group"); result = new GroupResult(group); break; case "theme": Theme theme = new Theme(); theme.Id = Convert.ToInt32(document.Get("ID")); theme.Name = document.Get("Theme"); theme.CourseRef = Convert.ToInt32(document.Get("CourseRef")); result = new ThemeResult(theme, _CourseService.GetCourse(theme.CourseRef).Name); break; default: throw new Exception("Unknown result type"); } results.Add(result); } sw.Stop(); DateTime dataend = DateTime.Now; analyzer.Close(); searcher.Close(); directory.Close(); ViewData["SearchString"] = query; ViewData["score"] = Math.Abs(dataend.Millisecond - datastart.Millisecond); //sw.ElapsedMilliseconds.ToString(); ViewData["total"] = total; return View(results); }
public IEnumerable<User> GetUsersNotInGroup(Group group) { var db = GetDbContext(); return db.Users.Where(u => !u.Deleted).Except(db.GroupUsers.Where(g => g.GroupRef == group.Id).Select(g => g.User)); }
public void CreateGroup(Group group) { using (var db = new UserManagementDBContext()) { group.Deleted = false; db.Groups.Add(group); db.SaveChanges(); } }
public void EditGroup(int id, Group group) { var db = GetDbContext(); var oldGroup = db.Groups.Single(g => g.Id == id && !g.Deleted); oldGroup.Name = group.Name; db.SubmitChanges(); _LmsService.Inform(UserNotifications.GroupEdit, group); }
public IEnumerable<User> GetUsersNotInGroup(Group group) { using (var db = new UserManagementDBContext()) { return db.Users.Where(u => !u.Deleted).Except(db.Users.Where(m => m.Groups.Contains(group))); //return db.Users.Where(u => !u.Deleted).Except(db.GroupUsers.Where(g => g.GroupRef == group.Id).Select(g => g.User)); } }
public GroupResult(Group group) { _Group = group; }
public void RemoveUserFromGroup(Group group, User user) { using (var db = new UserManagementDBContext()) { db.Users.Attach(user); db.Groups.Attach(group); db.Users.Remove(user); db.SaveChanges(); } }
partial void InsertGroup(Group instance);
partial void UpdateGroup(Group instance);
public IEnumerable<User> GetUsersByGroup(Group group) { throw new NotImplementedException(); }
public IEnumerable<User> GetUsersInGroup(Group group) { using (var db = new UserManagementDBContext()) { return db.Users.Where(u => u.Groups.Contains(group)); //return db.GroupUsers.Where(g => g.GroupRef == group.Id && !g.User.Deleted).Select(g => g.User); } }