コード例 #1
0
        public ActionResult Create(int projectId, int userId)
        {
            var model       = new ProjectUserFormModel();
            var projectUser = ProjectUserRepository.ProjectUserNew(projectId, userId);

            projectUser.RoleId = (int)Role.Collaborator;

            projectUser = ProjectUserRepository.ProjectUserSave(projectUser);

            return(this.RedirectToAction("Details", "Project", new { id = projectUser.ProjectId }));
        }
コード例 #2
0
        public static ProjectUser ProjectUserNew(Role roleId)
        {
            var project = ProjectTestHelper.ProjectAdd();
            var user    = UserTestHelper.UserAdd();

            var projectUserMember = ProjectUserRepository.ProjectUserNew(project.ProjectId, user.UserId);

            projectUserMember.RoleId = (int)roleId;

            return(projectUserMember);
        }
コード例 #3
0
        public ActionResult Create(int projectId)
        {
            var model       = new ProjectUserFormModel();
            var projectUser = ProjectUserRepository.ProjectUserNew(projectId, 0);

            model.Title        = "Project User Create";
            model.Users        = UserRepository.UserFetchInfoList();
            model.ProjectUser  = projectUser;
            model.ProjectUsers = ProjectUserRepository.ProjectUserFetchInfoList(projectId);

            return(this.View(model));
        }
コード例 #4
0
        public void ProjectUser_Create()
        {
            var projectUserMember = ProjectUserRepository.ProjectUserNew(0, 0);

            Assert.IsTrue(projectUserMember.IsNew, "IsNew should be true");
            Assert.IsTrue(projectUserMember.IsDirty, "IsDirty should be true");
            Assert.IsFalse(projectUserMember.IsValid, "IsValid should be false");
            Assert.IsTrue(projectUserMember.IsSelfDirty, "IsSelfDirty should be true");
            Assert.IsFalse(projectUserMember.IsSelfValid, "IsSelfValid should be false");

            Assert.IsTrue(
                ValidationHelper.ContainsRule(projectUserMember, DbType.Int32, "ProjectId"),
                "ProjectId should be required");

            Assert.IsTrue(
                ValidationHelper.ContainsRule(projectUserMember, DbType.Int32, "UserId"),
                "UserId should be required");

            Assert.IsTrue(
                ValidationHelper.ContainsRule(projectUserMember, DbType.Int32, "RoleId"),
                "RoleId should be required");
        }