public void UpdateProject_Test()
        {
            // ARRANGE
            CreateProject();
            var projectToUpdate = this.uow.Projects.GetAll().First();
            var updateParam     = new ProjectUpdateParam
            {
                Description = "Test description updated",
                Name        = "Test project updated"
            };
            var projectLogic = new ProjectLogic();

            // ACT
            projectLogic.UpdateProject(updateParam, projectToUpdate.Id);
            projectLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var updatedProject = this.uow.Projects.Get(projectToUpdate.Id);

            Assert.IsNotNull(updatedProject);
            Assert.AreNotEqual(projectToUpdate.Name, updatedProject.Name);
            Assert.AreEqual(updateParam.Name, updatedProject.Name);
            Assert.AreEqual(updateParam.Description, updatedProject.Description);
        }
Beispiel #2
0
        public ActionResult EditProject(Project project, Guid[] teamEmployees, Budget[] budgets, bool?clearBudgets)
        {
            ProjectLogic logic = new ProjectLogic();

            if (budgets == null && clearBudgets == true)
            {
                budgets = new Budget[0];
            }
            var result = logic.UpdateProject(project, teamEmployees, budgets);

            return(Json(new { Result = result }));
        }
        public ActionResult Edit([Bind(Include = "Id,Name")] ProjectViewModel projectViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(projectViewModel));
            }

            if (!_projectLogic.ProjectExists(projectViewModel.Id))
            {
                return(HttpNotFound("Project does not exist"));
            }

            _projectLogic.UpdateProject(new ProjectModel {
                Id = projectViewModel.Id, Name = projectViewModel.Name
            });
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        private void btn_AddProject_Click(object sender, RoutedEventArgs e)
        {
            if (this.SelectedProjectType != null && this.CanCreateProject && !editMode && !string.IsNullOrWhiteSpace(this.tb_projectDesignation.Text))
            {
                var bllProjectTypes = new ProjectTypeLogic();
                var bllProjects     = new ProjectLogic();
                var projectType     = bllProjectTypes.GetProjectType(this.SelectedProjectType.Id);
                var viewModel       = new ProjectCreateViewModel
                {
                    Description = tb_projectDescription.Text,
                    Name        = tb_projectDesignation.Text,
                    ProjectType = projectType
                };

                bllProjects.InsertProject(viewModel);
                bllProjects.Dispose();
                bllProjectTypes.Dispose();
                this.Close();
            }
            else if (this.SelectedProjectType != null && this.CanCreateProject && editMode)
            {
                var bllProjectTypes = new ProjectTypeLogic();
                var bllProjects     = new ProjectLogic();
                var projectType     = bllProjectTypes.GetProjectType(this.SelectedProjectType.Id);
                var viewModel       = new ProjectUpdateViewModel
                {
                    Description = this.tb_projectDescription.Text,
                    Name        = this.tb_projectDesignation.Text
                };

                bllProjects.UpdateProject(viewModel, projectId);
                bllProjects.Dispose();
                bllProjectTypes.Dispose();
                this.Close();
            }
        }