private async Task GetAllCompletedProjects_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); var userManager = this.GetMockUserManager().Object; this.adminService = new AdminService(userManager, context); var project = await this.adminService.GetAllProjectsInProgress(); var projectInputModel = new ProjectEditInputModel { Id = project[0].Id, IsPublic = project[0].IsPublic, Name = "Test-Edited", Status = ProjectStatus.Completed, }; await this.adminService.EditProject(projectInputModel); var completedProjects = await this.adminService.GetAllCompletedProjects(); Assert.Single(completedProjects); }
public async Task <IActionResult> Edit(string id, ProjectEditInputModel model) { if (this.ModelState.IsValid) { await this.adminService.EditProject(model); } return(this.Redirect("/Home/IndexLoggedin")); }
public async Task EditProject(ProjectEditInputModel model) { var projectFromBd = await this.GetProjectById(model.Id); if (projectFromBd.Status != model.Status || projectFromBd.Name != model.Name || projectFromBd.IsPublic != model.IsPublic) { projectFromBd.Status = model.Status; projectFromBd.Name = model.Name; projectFromBd.IsPublic = model.IsPublic; } this.context.Projects.Update(projectFromBd); await this.context.SaveChangesAsync(); }
public async Task <IActionResult> Edit(int id, ProjectEditInputModel inputModel) { if (id != inputModel.Id) { return(this.NotFound()); } if (!this.ModelState.IsValid) { return(this.View(inputModel)); } var project = await this.projectsService.EditByClientAsync <ProjectEditInputModel>(inputModel); return(this.RedirectToAction(nameof(this.Details), new { project.Id })); }
public async Task <IActionResult> Edit(int id, ProjectEditInputModel inputModel) { if (id != inputModel.Id) { return(this.NotFound()); } if (!this.ModelState.IsValid) { var selectedUsers = await this.SelectUsersAsync(this.User); var statuses = await this.progressStatusesService.GetAllAsync <ProjectProgressStatusViewModel>(); this.ViewData["Users"] = selectedUsers; this.ViewData["Statuses"] = statuses; return(this.View(inputModel)); } var project = await this.projectsService.EditByManagerAsync <ProjectEditInputModel>(inputModel); return(this.RedirectToAction(nameof(this.Details), new { project.Id })); }