public IActionResult EditScope(int?id) { if (id == null) { ViewData["ErrorMsg"] = "No Project Selected."; return(View("Edit")); } // Grabbing the Most Reccent Scope var scope = _context.Scopes.Where(S => S.ProjectId == id).OrderByDescending(S => S.ScopeVersion).First(); var projectname = _context.ProjectModel.Where(P => P.ID == scope.ProjectId).First().ProjectName; var CurrentScope = new EditScopeViewModel { ProjectId = scope.ProjectId, ScopeParent = scope.ID, // Hidden ProjectName = projectname, ScopeAuthor = User.Identity.Name, // Hidden ScopeCurrentVersion = scope.ScopeVersion, UpdatedScopeExpectations = scope.ScopeExpectations, UpdatedScopeGoals = scope.ScopeGoals, UpdatedScopeLimitations = scope.ScopeLimitations, UpdatedScopePhase = scope.ScopePhase, UpdatedScopePhaseNum = scope.ScopePhaseNumber, UpdatedScopePhaseNumberMax = scope.ScopeMaxPhaseNumber, UpdatedScopeSummary = scope.ScopeSummary, ScopeStartDate = scope.ScopeStartDate, ScopeEndDate = scope.ScopeEndDate, ScopeManager = scope.ScopeManager }; return(View(CurrentScope)); }
public async Task <IActionResult> EditScope(EditScopeViewModel scope) { // INCREMENT SCOPE VERSION var NewScope = new ScopeModel { ProjectId = scope.ProjectId, ParentScope = scope.ScopeParent, ScopeAuthor = scope.ScopeAuthor, ScopeExpectations = scope.UpdatedScopeExpectations, ScopeGoals = scope.UpdatedScopeGoals, ScopeLimitations = scope.UpdatedScopeLimitations, ScopeManager = scope.ScopeManager, ScopeSummary = scope.UpdatedScopeSummary, ScopeVersion = _context.Scopes.Where(S => S.ProjectId == scope.ProjectId).Count(), ScopeMaxPhaseNumber = scope.UpdatedScopePhaseNumberMax, ScopePhaseNumber = scope.UpdatedScopePhaseNum, ScopePhase = scope.UpdatedScopePhase, ScopeEndDate = scope.ScopeEndDate, ScopeStartDate = scope.ScopeStartDate, }; _context.Scopes.Add(NewScope); await _context.SaveChangesAsync(); ViewData["Msg"] = "Updated Scope and Added to Database"; return(RedirectToAction("Index")); }
public async Task <IActionResult> EditScope( [FromRoute] string id, [FromRoute] string scope, [FromForm] EditScopeViewModel model) { var application = await _applicationManager.FindByIdAsync(id); var applicationName = await _applicationManager.GetApplicationNameAsync(application); if (!ModelState.IsValid) { return(View(new EditScopeViewModel(applicationName, scope))); } var result = await _applicationManager.UpdateScopeAsync(application, scope, model.Scope); if (!result.Succeeded) { MapErrorsToModelState("", result); return(View(new EditScopeViewModel(applicationName, scope))); } return(RedirectToAction(nameof(Details), new { id })); }