public void Setup() { this.projectRepositoryMock = new Mock<IProjectRepository>(); this.userRepositoryMock = new Mock<IUserRepository>(); this.projectProcessor = new ProjectProcessor(this.projectRepositoryMock.Object, this.userRepositoryMock.Object); this.users = new List<User> { new User { Id = 1, UserName = "******" } }; this.creator = new User { Id = 1, UserName = "******" }; this.project = new Project { Name = "Test project", Creator = creator, ProjectUsers = users }; this.projectRepositoryMock.Setup(it => it.GetAllUsersInProject(project.Id)).Returns(users); this.projectRepositoryMock.Setup(it => it.GetCreatorForProject(project.Id)).Returns(creator); }
public ActionResult AddProject(string projectName) { var user = userRepository.GetByName(User.Identity.Name); var project = new Project { Created = DateTime.Now, Creator = user, Name = projectName, CreatorId = user.Id }; var id = projectRepository.Add(project); var projectsToModel = new LandingProjectModel { Id = id, Name = projectName }; return Json(projectsToModel); }
/// <summary> /// The update. /// </summary> /// <param name="project"> /// The project. /// </param> public void Update(Project project) { this.dataBaseContext.Entry(project).State = EntityState.Modified; this.dataBaseContext.SaveChanges(); }
/// <summary> /// The add. /// </summary> /// <param name="project"> /// The project. /// </param> public int Add(Project project) { this.dataBaseContext.Entry(project).State = EntityState.Added; this.dataBaseContext.SaveChanges(); return project.Id; }
public ActionResult EditProject(Project project) { if (this.ModelState.IsValid) { this.projectRepository.Update(project); return this.RedirectToAction("AdminPanel"); } return this.View(project); }
/// <summary> /// The create custom project with project name and description. /// </summary> /// <param name="user"> /// The user tied to project. /// </param> /// <param name="projectName"> /// The project name. /// </param> /// <param name="projectDescription"> /// The project description. /// </param> public void CreateProject(User user, string projectName, string projectDescription) { var project = new Project { CreatorId = user.Id, Creator = user, Created = DateTime.Now, Name = projectName, Description = projectDescription }; this.projectRepository.Add(project); }