예제 #1
0
        public ActionResult Edit(EditProjectModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Redirect(Url.Project_Edit(model.Id)));
            }
            ProjectObj project;

            if (!model.Id.HasValue)
            {
                project    = ModelConverter.Convert(model);
                project.Id = ProjectLogic.Create(project, CurrentUserName);
                if (project.Id == -1)
                {
                    this.AddError("CreatingProject", "There was an error creating your project. If this continues contact support.");
                    return(Redirect(Url.Project_Create()));
                }
            }
            else
            {
                project = ModelConverter.Convert(model);
                var success = ProjectLogic.Update(project, CurrentUserName);
                if (!success)
                {
                    this.AddError("UpdatingProject", "There was an error updating your project. If this continues contact support.");
                    return(Redirect(Url.Project_Edit(model.Id.Value)));
                }
            }

            return(Redirect(Url.Project_Show(project.Id.Value)));
        }
예제 #2
0
        public void Update_Id_Found()
        {
            //arrange
            bool expected       = true;
            var  mockRepository = new Mock <IInnerTrackRepository>();
            var  updateProj     = new ProjectObj {
                Id = 2
            };
            var user = "******";

            mockRepository.Setup(m => m.UpdateProject(updateProj, user)).Returns(expected);
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.Update(updateProj, user);

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Project p = new Project();

            p.Name        = txtName.Text;
            p.Description = txtDescription.Text;
            p.CreatedAt   = DateTime.Now;

            if (_projectToUpdate == null)
            {
                ProjectLogic.Add(p);
            }
            else
            {
                ProjectLogic.Update(_projectToUpdate, p);
            }

            Close();
        }