Exemplo n.º 1
0
        public ActionResult AddProject()
        {
            CheckUserAuthorization();
            decimal      userId  = BaseBindings.CookiesManager.GetCookieValueDecimal(Request, CookieType.UserId);
            ProjectModel project = new ProjectModel();

            //TODO change the role id to the loaded from the DB
            project.AddUserToProject(userId, 0);
            ViewBag.IsNewProject = true;
            return(View("CreateProject", project));
        }
Exemplo n.º 2
0
 public ActionResult SaveProject(ProjectModel project)
 {
     CheckUserAuthorization();
     if (project.Id <= 0)
     {
         decimal userId = BaseBindings.CookiesManager.GetCookieValueDecimal(Request, CookieType.UserId);
         project.AddUserToProject(userId, 0);
     }
     //TODO change the role id to the loaded from the DB
     if (project.SaveProject())
     {
         return(RedirectToAction("Index", "Projects"));
     }
     return(View("CreateProject"));
 }
Exemplo n.º 3
0
        public void SuccessSaveProjectTest()
        {
            MsSqlFactory        factory      = new MsSqlFactory(Common.Connectionconfig);
            IDataBaseProvider   provider     = factory.CreateDBProvider();
            IUserAccessProvider usProvider   = factory.CreateUserAccessProvider();
            UserModel           userModel    = null;
            ProjectModel        projectModel = null;

            try
            {
                userModel = new UserModel(usProvider)
                {
                    UserDetails = SaveANewUser(provider, usProvider)
                };
                projectModel = new ProjectModel(provider)
                {
                    ProjectDetails = new EProject
                    {
                        ProjectName = "Test project name 1",
                        Description = "ProjectDescr"
                    }
                };
                projectModel.AddUserToProject(userModel.UserDetails.Id, 0);
                Assert.IsTrue(projectModel.SaveProject(), "Unable to save project");
                Assert.IsTrue(
                    projectModel.ProjectDetails.Id > 0,
                    $"Retuen the bad project ID: {projectModel.ProjectDetails.Id}");
                var context = ((DataProvider)provider).GenerateContext();
                Assert.IsNotNull(
                    context.User_Project.FirstOrDefault(
                        u => u.ID_Project == projectModel.ProjectDetails.Id),
                    "User_project is not saved");
            }
            finally
            {
                if (projectModel != null && projectModel.ProjectDetails.Id > 0)
                {
                    provider.DeleteProject(projectModel.ProjectDetails.Id);
                }
                using (var context = ((DataProvider)provider).GenerateContext())
                {
                    DeleteUserFromDB(context, userModel?.UserDetails?.Login, userModel?.UserDetails?.EMail);
                }
            }
        }