예제 #1
0
 public ActionResult AddProject(Project model)
 {
     if (ModelState.IsValid)
     {
         projectLogic.createProject(model.Name, model.Priority);
     }
     return(RedirectToAction("Index", "Project"));
 }
        private void btnAddProject_Click(object sender, EventArgs e)
        {
            Project project = new Project();

            project.ProjectCode = txtProjectCode.Text;
            if (txtName.Text != "")
            {
                project.Name = txtName.Text;
            }
            else
            {
                MessageBox.Show("Please enter project Name");
                txtName.Focus();
                txtName.BackColor = Color.Red;
                return;
            }
            switch (userLogged.Role)
            {
            case 0:
                project.ProjectManager = cmbProjectManager.SelectedItem.ToString();
                project.User           = (User)cmbProjectManager.SelectedItem;
                break;

            case 1:
                project.ProjectManager = userLogged.Username;
                project.User           = userLogged;
                break;

            default:
                MessageBox.Show("You don't have permision create Project");
                return;
            }

            bool pass = projectLogic.createProject(project);

            if (pass)
            {
                MessageBox.Show("Project saved successfully");
            }
            else
            {
                MessageBox.Show("System can't save project");
            }
            refreshInputs();
        }
        public void T_createProject_CanCreateProject_ReturnTrue()
        {
            var     projectLogic = new ProjectLogic();
            Project project      = new Project();

            project.ProjectCode = ProjectCodeTest;
            project.Name        = "ProjectTest";
            project.User        = new User()
            {
                Username = "******"
            };
            project.ProjectManager = "igorpanic";


            var result = projectLogic.createProject(project);

            Assert.IsTrue(result);
        }