public async Task <IActionResult> ProjectDetails(ProjectDetailsAndAssociatedBugs projectUpdates) { var originalProject = _projectRepository.GetProject(projectUpdates.Project.ProjectId); var userId = userManager.GetUserId(HttpContext.User); var user = await userManager.FindByIdAsync(userId); var claims = await userManager.GetClaimsAsync(user); GlobalVar.globalCurrentUserClaims = claims.ToList(); foreach (var property in originalProject.GetType().GetProperties()) { var oldValue = ""; var newValue = ""; if (property.GetValue(projectUpdates.Project) != null) { newValue = property.GetValue(projectUpdates.Project).ToString(); } if (property.GetValue(originalProject) != null) { oldValue = property.GetValue(originalProject).ToString(); } if (oldValue != newValue) { var changes = new ProjectHistory { AssociatedProjectId = originalProject.ProjectId, Property = property.Name, OldValue = oldValue, NewValue = newValue, DateChanged = DateTime.Now }; _projectRepository.AddHistoryEntry(changes); } } var projectBugs = _bugRepository.GetAllProjectBugs(projectUpdates.Project.ProjectId); var project = _projectRepository.Update(projectUpdates.Project); var projectHistory = _projectRepository.GetProjectHistories(projectUpdates.Project.ProjectId); var viewModel = new ProjectDetailsAndAssociatedBugs() { Project = project, ProjectBugs = projectBugs, projectHistories = projectHistory, ProjectId = GlobalVar.ProjectId }; return(View(viewModel)); }