コード例 #1
0
ファイル: CreateNewGroup.cs プロジェクト: supermuk/iudico
 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);
 }
コード例 #2
0
ファイル: DeleteGroup.cs プロジェクト: supermuk/iudico
 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 );
 }
コード例 #3
0
        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();
        }
コード例 #4
0
        public void CreateGroup(Group group)
        {
            var db = GetDbContext();

            group.Deleted = false;

            db.Groups.InsertOnSubmit(group);
            db.SubmitChanges();
        }
コード例 #5
0
ファイル: GroupController.cs プロジェクト: supermuk/iudico
 public ActionResult Edit(int id, Group group)
 {
     if (ModelState.IsValid && Storage.EditGroup(id, group))
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(group);
     }
 }
コード例 #6
0
ファイル: GroupController.cs プロジェクト: supermuk/iudico
 public ActionResult Create(Group group)
 {
     if (ModelState.IsValid && Storage.CreateGroup(group))
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(group);
     }
 }
コード例 #7
0
ファイル: DatabaseUMStorage.cs プロジェクト: supermuk/iudico
 public bool CreateGroup(Group group)
 {
     try
     {
         db.Groups.InsertOnSubmit(group);
         db.SubmitChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #8
0
 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 };
 }
コード例 #9
0
ファイル: DatabaseUMStorage.cs プロジェクト: supermuk/iudico
 public bool EditGroup(int id, Group group)
 {
     try
     {
         Group oldGroup = GetGroup(id);
         oldGroup.Name = group.Name;
         db.SubmitChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: StatisticsStorage.cs プロジェクト: supermuk/iudico
 public IEnumerable<User> GetUsersBySelectedGroup(Group group)
 {
     return _LmsService.FindService<IUserService>().GetUsersByGroup(group);
 }
コード例 #12
0
ファイル: UserService.cs プロジェクト: supermuk/iudico
 public IEnumerable<User> GetUsersByGroup(Group group)
 {
     return _UserStorage.GetUsersInGroup(group);
 }
コード例 #13
0
ファイル: CurriculumTests.cs プロジェクト: supermuk/iudico
 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());
 }
コード例 #14
0
 partial void DeleteGroup(Group instance);
コード例 #15
0
        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();
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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();
            }
        }
コード例 #18
0
ファイル: SearchController.cs プロジェクト: supermuk/iudico
        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);
        }
コード例 #19
0
        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));
        }
コード例 #20
0
        public void CreateGroup(Group group)
        {
            using (var db = new UserManagementDBContext())
            {
                group.Deleted = false;

                db.Groups.Add(group);
                db.SaveChanges();
            }
        }
コード例 #21
0
        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);
        }
コード例 #22
0
 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));
     }
 }
コード例 #23
0
ファイル: GroupResult.cs プロジェクト: supermuk/iudico
 public GroupResult(Group group)
 {
     _Group = group;
 }
コード例 #24
0
        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();
            }
        }
コード例 #25
0
 partial void InsertGroup(Group instance);
コード例 #26
0
 partial void UpdateGroup(Group instance);
コード例 #27
0
ファイル: FakeUserService.cs プロジェクト: supermuk/iudico
 public IEnumerable<User> GetUsersByGroup(Group group)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
 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);
     }
 }