Example #1
0
        public async Task Test_add_project_and_update_project_manager_if_project_manager_exists()
        {
            var user = new User("teste", "*****@*****.**", "123");
            var userRepositoryMock = new Mock <IUserRepository>();
            var uowMock            = new Mock <IUnitOfWork>();

            userRepositoryMock
            .Setup(u => u.GetByIdentifierAsync(user.Identifier))
            .ReturnsAsync(user);

            var projectManagerRepositoryMock = new Mock <IProjectManagerRepository>();

            projectManagerRepositoryMock.Setup(c => c.GetByUserIdentifierAsync(It.IsAny <Guid>())).ReturnsAsync(new ProjectManager(Guid.NewGuid()));
            projectManagerRepositoryMock.SetupGet(c => c.UnitOfWork).Returns(uowMock.Object);

            var service = new ProjectManagementService(userRepositoryMock.Object, projectManagerRepositoryMock.Object);

            var data = new NewProject {
                Title      = "hello",
                StartDate  = DateTime.Now,
                FinishDate = DateTime.Now.AddDays(3)
            };

            var result = await service.CreateProject(user.Identifier, data);

            projectManagerRepositoryMock.Verify(c => c.GetByUserIdentifierAsync(It.IsAny <Guid>()), Times.Once());
            projectManagerRepositoryMock.Verify(c => c.Add(It.IsAny <ProjectManager>()), Times.Never());
            projectManagerRepositoryMock.Verify(c => c.Update(It.IsAny <ProjectManager>()), Times.Once());
            uowMock.Verify(c => c.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once());
        }
Example #2
0
        public IList <SelectListItem> GetDeveloperNames()
        {
            var _context     = new UsersManagementService();
            var context      = new ProjectManagementService();
            var projectUsers = context.GetProjectUsers(ProjectId).ToList().Where(e => e.ProjectRoleId == 1);

            var users = new List <User>();

            var currProjectUser =
                context.GetProjectUsers(ProjectId).Single(e => e.UserId == WebSecurity.CurrentUserId);

            if (currProjectUser.ProjectRoleId == 1)
            {
                users.Add(_context.GetUser(currProjectUser.UserId));
            }
            else
            {
                foreach (var user in projectUsers)
                {
                    users.Add(_context.GetUser(user.UserId));
                }
            }

            return(users.Select(e => new SelectListItem
            {
                Text = context.GetCreatorName(e.Id),
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
Example #3
0
        public BugListViewModel FromBug(Bug bug)
        {
            var context = new ProjectManagementService();

            var isAssigned = false;
            var user       = context.GetProjectsOfUser(WebSecurity.CurrentUserId).Count(e => e.ProjectId == bug.ProjectId && e.UserId == WebSecurity.CurrentUserId);

            if (user != 0)
            {
                isAssigned = true;
            }

            return(new BugListViewModel
            {
                Id = bug.Id,
                Steps = bug.Steps,
                Symptom = GetSymptomName(bug.SymptomId),
                ProjectId = bug.ProjectId,
                ReporterName = context.GetCreatorName(bug.ReporterId),
                ReportingDate = bug.ReportingDate.ToShortDateString(),
                Summary = string.Format("<a href=\"{0}\">{1}</a>", Url.Action("BugDetails", "BTS", new { id = bug.Id }), bug.Summary),
                Severity = GetSeverityName(bug.SeverityId),
                Status = GetStatusName(bug.StatusId),
                StatusId = bug.StatusId,
                Project = GetProjectTitle(bug.ProjectId),
                ModifyingDate = bug.ModifyingDate.ToShortDateString(),
                AssignedDeveloperName = (bug.AssignedDeveloperId == 0) ? "отсутствует" : context.GetCreatorName(bug.AssignedDeveloperId),
                IsAssigned = isAssigned
            });
        }
Example #4
0
        public static string GetProjectTitle(int id)
        {
            var projectManagementService = new ProjectManagementService();
            var project = projectManagementService.GetProject(id);

            return(project.Title);
        }
Example #5
0
        public ProjectListViewModel FromProject(Project project)
        {
            var context    = new LmPlatformModelsContext();
            var isAssigned = false;

            foreach (var user in context.ProjectUsers)
            {
                if (user.ProjectId == project.Id && user.UserId == WebSecurity.CurrentUserId)
                {
                    isAssigned = true;
                }
            }

            var _context  = new ProjectManagementService();
            var creatorId = project.Creator.Id;

            return(new ProjectListViewModel
            {
                Id = project.Id,
                Title =
                    string.Format("<a href=\"{0}\">{1}</a>", Url.Action("ProjectManagement", "BTS", new { id = project.Id }), project.Title),
                CreatorName = _context.GetCreatorName(creatorId),
                CreationDate = project.DateOfChange.ToShortDateString(),
                UserQuentity = _context.GetProjectUsers(project.Id).Count,
                IsAssigned = isAssigned
            });
        }
        public bool IsProjectManager()
        {
            var projectUser = new ProjectManagementService().GetProjectUsers(ProjectId)
                              .Count(e => e.UserId == /*todo #auth WebSecurity.CurrentUserId*/ 2 && e.ProjectRoleId == 3);

            return(projectUser != 0);
        }
Example #7
0
        public ProjectsViewModel(int projectId)
        {
            CreateStaticLists();
            var model = ProjectManagementService.GetProject(projectId);

            ProjectId = projectId;
            SetParams(model);
        }
 public void Update(int projectId)
 {
     ProjectManagementService.UpdateProject(new Project
     {
         Id    = projectId,
         Title = Title
     });
 }
Example #9
0
        public bool DeleteUser(int id)
        {
            using var repositoriesContainer = new LmPlatformRepositoriesContainer();

            var query = new Query <User>().AddFilterClause(u => u.Id == id).Include(u => u.ProjectUsers).Include(u => u.Student);
            var user  = repositoriesContainer.UsersRepository.GetBy(query);

            repositoriesContainer.MessageRepository.DeleteUserMessages(user.Id);

            var projects = user.ProjectUsers.DistinctBy(e => e.ProjectId).Select(e => e.ProjectId);

            foreach (var projectId in projects)
            {
                ProjectManagementService.DeleteUserFromProject(id, projectId);
            }

            if (user.Student != null)
            {
                var acp = user.Student.AssignedCourseProjects.Select(e => e.CourseProjectId);
                foreach (var acpId in acp)
                {
                    CPManagementService.DeleteUserFromAcpProject(id, acpId);
                }

                var subjects = repositoriesContainer.RepositoryFor <SubjectStudent>()
                               .GetAll(new Query <SubjectStudent>(e => e.StudentId == id));

                foreach (var subjectS in subjects)
                {
                    repositoriesContainer.RepositoryFor <SubjectStudent>().Delete(subjectS);
                }

                var diplomas = Context.AssignedDiplomProjects.Where(e => e.StudentId == id).ToList();

                var diplomasRessList = Context.DiplomPercentagesResults.Where(e => e.StudentId == id).ToList();

                foreach (var diploma in diplomas)
                {
                    Context.AssignedDiplomProjects.Remove(diploma);
                    Context.SaveChanges();
                }

                foreach (var diplomasRes in diplomasRessList)
                {
                    Context.DiplomPercentagesResults.Remove(diplomasRes);
                    Context.SaveChanges();
                }
            }

            CPManagementService.DeletePercenageAndVisitStatsForUser(id);

            repositoriesContainer.ApplyChanges();
            var result = AccountManagementService.DeleteAccount(user.UserName);

            repositoriesContainer.ApplyChanges();

            return(result);
        }
Example #10
0
        public static string GetProjectCreatorName(int projectId)
        {
            var context  = new LmPlatformModelsContext();
            var _context = new ProjectManagementService();
            var project  = context.Projects.Find(projectId);
            var creator  = context.Users.Find(project.CreatorId);

            return(_context.GetCreatorName(creator.Id));
        }
Example #11
0
        public IList <SelectListItem> GetProjectNames()
        {
            var projects = ProjectManagementService.GetProjects();

            return(projects.Select(e => new SelectListItem
            {
                Text = e.Title,
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
Example #12
0
 public BugListViewModel(int id)
 {
     CurrentProjectId   = id;
     CurrentProjectName = string.Empty;
     if (id != 0)
     {
         var project = new ProjectManagementService().GetProject(id);
         CurrentProjectName = project.Title;
     }
 }
Example #13
0
        public bool IsProjectManager()
        {
            var projectUser = new ProjectManagementService().GetProjectUsers(ProjectId).Count(e => e.UserId == WebSecurity.CurrentUserId && e.ProjectRoleId == 3);

            if (projectUser == 0)
            {
                return(false);
            }

            return(true);
        }
        public void SaveAssignment()
        {
            var projectUser = new ProjectUser
            {
                UserId        = UserId,
                ProjectId     = Id,
                ProjectRoleId = RoleId
            };

            ProjectManagementService.AssingRole(projectUser);
        }
Example #15
0
        public void SaveProject()
        {
            var creatorId = WebSecurity.CurrentUserId;

            ProjectManagementService.SaveProject(new Project
            {
                Title        = Title,
                CreatorId    = creatorId,
                CreationDate = DateTime.Today
            });
        }
        public IList <SelectListItem> GetProjectNames()
        {
            var projectUsers = new ProjectManagementService().GetProjectsOfUser(/*todo #auth WebSecurity.CurrentUserId*/ 2);
            var projects     = projectUsers.Select(projectUser => new ProjectManagementService().GetProject(projectUser.ProjectId)).ToList();

            return(projects.Select(e => new SelectListItem
            {
                Text = e.Title,
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).OrderBy(e => e.Text).ToList());
        }
Example #17
0
        public DataTablesResult <ProjectListViewModel> GetProjects(DataTablesParam dataTableParam)
        {
            var searchString = dataTableParam.GetSearchString();
            var projects     = ProjectManagementService.GetProjects(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);

            if (User.IsInRole("lector"))
            {
                return(DataTableExtensions.GetResults(projects.Items.Select(model => FromProject(model, PartialViewToString("_ProjectsGridActions", FromProject(model)))).Where(e => e.IsAssigned), dataTableParam, projects.TotalCount));
            }

            return(DataTableExtensions.GetResults(projects.Items.Select(FromProject).Where(e => e.IsAssigned), dataTableParam, projects.TotalCount));
        }
Example #18
0
        public List <string> GetProjectRoleList(int studentId)
        {
            var projectUserList = new ProjectManagementService().GetProjectsOfUser(studentId).ToList();
            var projectRoleList = new List <string>();

            foreach (var project in projectUserList)
            {
                projectRoleList.Add(project.ProjectRole.Name);
            }

            return(projectRoleList);
        }
Example #19
0
        private bool Copy_Stage(int pProjectNo, int pProjectNo_Clone)
        {
            //XmlSerializer serializer = new XmlSerializer(typeof(PM_StageData));
            oCompServ  = (CompanyService)oCompany.GetCompanyService();
            pmgService = (ProjectManagementService)oCompServ.GetBusinessService(ServiceTypes.ProjectManagementService);
            PM_ProjectDocumentParams projectParam = (PM_ProjectDocumentParams)pmgService.GetDataInterface(ProjectManagementServiceDataInterfaces.pmsPM_ProjectDocumentParams);

            projectParam.AbsEntry = pProjectNo;
            PM_ProjectDocumentData project = pmgService.GetProject(projectParam);

            PM_ProjectDocumentParams projectCloneParam = (PM_ProjectDocumentParams)pmgService.GetDataInterface(ProjectManagementServiceDataInterfaces.pmsPM_ProjectDocumentParams);

            projectCloneParam.AbsEntry = pProjectNo_Clone;
            PM_ProjectDocumentData projectclone = pmgService.GetProject(projectCloneParam);

            foreach (PM_StageData sta_tmp in project.PM_StagesCollection)
            {
                PM_StageData tmp = projectclone.PM_StagesCollection.Add();
                tmp.StartDate   = sta_tmp.StartDate;
                tmp.Description = sta_tmp.Description;
                pmgService.UpdateProject(projectclone);
            }
            //Khong con cach nao khac - Can thiep tho bao vao DB voi cac truong UDF cua Stage
            //SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
            //string str_comand = "Update A Set";
            //string UDF = ConfigurationManager.AppSettings["UDF_Project_Stage"].ToString();
            //if (!string.IsNullOrEmpty(UDF))
            //{
            //    foreach (string field in UDF.Split(','))
            //    {
            //        str_comand = str_comand + string.Format(" a.{0} = b.{1} ,", field, field);
            //    }
            //    str_comand = str_comand.Substring(0, str_comand.Length - 1);
            //    str_comand += string.Format("From PMG1 as a inner join (Select * from PMG1 where  AbsEntry = {0}) as b on a.LineID = b.LineID where a.AbsEntry = {1}", pProjectNo, pProjectNo_Clone);
            //    SqlCommand cmd = new SqlCommand(str_comand, conn);
            //    try
            //    {
            //        conn.Open();
            //        cmd.ExecuteNonQuery();
            //    }
            //    catch (Exception ex)
            //    {
            //        return false;
            //    }
            //    finally
            //    {
            //        conn.Close();
            //        cmd.Dispose();
            //    }

            //}
            return(true);
        }
Example #20
0
        public ProjectUserListViewModel FromProjectUser(ProjectUser projectUser)
        {
            var context = new ProjectManagementService();

            return(new ProjectUserListViewModel
            {
                Id = projectUser.Id,
                UserName = context.GetCreatorName(projectUser.User.Id),
                RoleName = GetRoleName(projectUser.ProjectRoleId),
                ProjectId = projectUser.ProjectId
            });
        }
Example #21
0
        public void SaveComment(string comment)
        {
            var currentUserId = WebSecurity.CurrentUserId;
            var newComment    = new ProjectComment
            {
                CommentText    = comment,
                ProjectId      = ProjectId,
                UserId         = currentUserId,
                CommentingDate = DateTime.Now
            };

            ProjectManagementService.SaveComment(newComment);
        }
Example #22
0
        public AssignUserViewModel(int id, int projectId)
        {
            ProjectId = projectId;

            if (id != 0)
            {
                var projectUser = ProjectManagementService.GetProjectUser(id);
                ProjectId = projectUser.ProjectId;
                RoleId    = projectUser.ProjectRoleId;
                UserId    = projectUser.UserId;
                Id        = projectUser.Id;
            }
        }
        public AddOrEditProjectViewModel(int projectId)
        {
            ProjectId = projectId;

            if (projectId != 0)
            {
                var project = ProjectManagementService.GetProject(projectId);
                CreatorId    = project.CreatorId;
                Details      = project.Details;
                DateOfChange = project.DateOfChange;
                ProjectId    = project.Id;
                Title        = project.Title;
            }
        }
Example #24
0
        public DataTablesResult <ProjectUserListViewModel> GetProjectUsers(DataTablesParam dataTablesParam)
        {
            var searchString = dataTablesParam.GetSearchString();
            var projectUsers = ProjectManagementService.GetProjectUsers(pageInfo: dataTablesParam.ToPageInfo(),
                                                                        searchString: searchString);
            var projectId = int.Parse(Request.QueryString["projectId"]);

            if (User.IsInRole("lector") && ProjectManagementService.GetProject(projectId).CreatorId == WebSecurity.CurrentUserId)
            {
                return(DataTableExtensions.GetResults(projectUsers.Items.Select(model => FromProjectUser(model, PartialViewToString("_ProjectUsersGridActions", FromProjectUser(model)))).Where(e => e.ProjectId == projectId && e.UserName != GetProjectCreatorName(projectId)), dataTablesParam, projectUsers.TotalCount));
            }

            return(DataTableExtensions.GetResults(projectUsers.Items.Select(FromProjectUser).Where(e => e.ProjectId == projectId && e.UserName != GetProjectCreatorName(projectId)), dataTablesParam, projectUsers.TotalCount));
        }
Example #25
0
        public List <string> GetProjectCreatorNameList(int studentId)
        {
            var context                = new ProjectManagementService();
            var projectUserList        = context.GetProjectsOfUser(studentId).ToList();
            var projectCreatorNameList = new List <string>();

            foreach (var project in projectUserList)
            {
                var creator =
                    new LmPlatformRepositoriesContainer().UsersRepository.GetBy(
                        new Query <User>(e => e.Id == project.Project.CreatorId));
                projectCreatorNameList.Add(context.GetCreatorName(creator.Id));
            }

            return(projectCreatorNameList);
        }
Example #26
0
        public IList <SelectListItem> GetProjectNames()
        {
            var projectUsers = new ProjectManagementService().GetProjectsOfUser(WebSecurity.CurrentUserId);
            var projects     = new List <Project>();

            foreach (var projectUser in projectUsers)
            {
                projects.Add(new ProjectManagementService().GetProject(projectUser.ProjectId));
            }

            return(projects.Select(e => new SelectListItem
            {
                Text = e.Title,
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
Example #27
0
        public ActionResult SaveBug(AddOrEditBugViewModel model)
        {
            model.Save(WebSecurity.CurrentUserId, _currentProjectId);
            var bugLog = new BugLog
            {
                BugId        = model.BugId,
                UserId       = WebSecurity.CurrentUserId,
                UserName     = ProjectManagementService.GetCreatorName(WebSecurity.CurrentUserId),
                PrevStatusId = _prevBugStatus,
                CurrStatusId = model.StatusId,
                LogDate      = DateTime.Now
            };

            if (model.BugId != 0)
            {
                model.SaveBugLog(bugLog);
            }

            return(null);
        }
Example #28
0
        public void SetParams(Bug model)
        {
            var context = new ProjectManagementService();

            Steps                 = model.Steps;
            ExpectedResult        = model.ExpectedResult;
            Symptom               = GetSymptomName(model.SymptomId);
            EditorName            = context.GetCreatorName(model.EditorId);
            ReporterName          = context.GetCreatorName(model.ReporterId);
            Summary               = model.Summary;
            Description           = model.Description;
            Severity              = GetSeverityName(model.SeverityId);
            Status                = GetStatusName(model.StatusId);
            Project               = GetProjectTitle(model.ProjectId);
            ProjectId             = model.ProjectId;
            ModifyingDate         = model.ModifyingDate.ToShortDateString();
            ReportingDate         = model.ReportingDate.ToShortDateString();
            AssignedDeveloperId   = model.AssignedDeveloperId;
            AssignedDeveloperName = (AssignedDeveloperId == 0) ? "-" : context.GetCreatorName(AssignedDeveloperId);
        }
Example #29
0
        public ActionResult EditBug(int id)
        {
            var bug = BugManagementService.GetBug(id);

            _currentProjectId = bug.ProjectId;

            var bugViewModel = new AddOrEditBugViewModel(id);

            _prevBugStatus = bugViewModel.StatusId;
            var projectUser =
                new ProjectManagementService().GetProjectUsers(bug.ProjectId).Single(e => e.UserId == WebSecurity.CurrentUserId);

            if ((projectUser.ProjectRoleId == 1 && bug.StatusId == 2) ||
                (projectUser.ProjectRoleId == 3 && bug.StatusId == 1))
            {
                return(PartialView("_EditBugFormWithAssignment", bugViewModel));
            }

            return(PartialView("_EditBugFormWithAssignment", bugViewModel));
        }
Example #30
0
        public IList <SelectListItem> GetLecturers()
        {
            var lecturers = new LecturerManagementService().GetLecturers();

            var lecturerList = new List <Lecturer>();

            foreach (var lecturer in lecturers)
            {
                if (ProjectManagementService.IsUserAssignedOnProject(lecturer.Id, ProjectId) == false)
                {
                    lecturerList.Add(lecturer);
                }
            }

            return(lecturerList.Select(v => new SelectListItem
            {
                Text = v.LastName + " " + v.FirstName + " " + v.MiddleName,
                Value = v.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }