public async Task <IActionResult> OnGetAsync(String projectName, Int32 pageNumber = 0) { CurrentPage = pageNumber; CurrentProject = await _projectsService.GetProjectByName(projectName.ToLower(), pageNumber, PageSize); _nextPageAvailable = CurrentProject.NumberOfTasks - (pageNumber * PageSize) > PageSize; return(Page()); }
public async Task <ExistingProjectWithTasks> GetProjectByName(String name, Int32 pageNumber, Int32 pageSize) { _logger.LogInformation($"Getting Project: {name}"); ExistingProjectWithTasks project = await _projectsRepository.GetProjectByName(name) as ExistingProjectWithTasks; project.ID = project.RowKey; _logger.LogInformation($"Getting Tasks for Project: {name}"); IEnumerable <ProjectTaskEntity> tasks = await _tasksRepository.GetTasksForProject(name); IEnumerable <ProjectTask> newTasks = tasks.Select(task => { return(ProjectTask.CreateFromEntity(task)); }); project.ProjectTasks = newTasks.Skip(pageNumber * pageSize).Take(pageSize).ToList(); project.NumberOfTasks = tasks.Count(); return(project); }
public async Task UpdateCurrentProject(ExistingProjectWithTasks project) { _logger.LogInformation($"Updating Project : {project.ProjectName}"); Project projectToUpdate = new Project { Private = project.Private, RowKey = project.ID, ProjectName = project.ProjectName }; await _projectsRepository.Update(projectToUpdate); _logger.LogInformation($"Updating all Tasks for {project.ProjectName}"); foreach (ProjectTask task in project.ProjectTasks) { task.PartitionKey = project.ID; task.RowKey = task.ID; } await _tasksRepository.UpdateAll(project.ProjectTasks); }