예제 #1
0
        public async Task <IActionResult> SetUserSelectedProject(string projectId)
        {
            GoNorthProject project = await _projectDbAccess.GetProjectById(projectId);

            if (project == null)
            {
                return(NotFound());
            }

            string userId = _userManager.GetUserId(this.User);
            await _projectDbAccess.SetUserSelectedProject(userId, project.Id);

            return(Ok());
        }
예제 #2
0
        /// <summary>
        /// Fills the task board history
        /// </summary>
        /// <param name="response">Response to send</param>
        /// <param name="currentUser">Current user</param>
        /// <returns>Task</returns>
        private async Task FillTaskBoardHistory(PersonalDataResponse response, GoNorthUser currentUser)
        {
            response.TaskBoardHistory = new List <TrimmedTaskBoardHistory>();

            List <UserTaskBoardHistory> taskBoardHistory = await _userTaskBoardHistoryDbAccess.GetAllOpenedBoardsOfUser(currentUser.Id);

            foreach (UserTaskBoardHistory curTaskBoard in taskBoardHistory)
            {
                TrimmedTaskBoardHistory curTaskBoardHistory = new TrimmedTaskBoardHistory();
                curTaskBoardHistory.BoardName = "DELETED";
                curTaskBoardHistory.Project   = "DELETED";

                TaskBoard taskBoard = await _taskBoardDbAccess.GetTaskBoardById(curTaskBoard.LastOpenBoardId);

                if (taskBoard != null)
                {
                    curTaskBoardHistory.BoardName = taskBoard.Name;
                }

                GoNorthProject project = await _projectDbAccess.GetProjectById(curTaskBoard.ProjectId);

                if (project != null)
                {
                    curTaskBoardHistory.Project = project.Name;
                }

                response.TaskBoardHistory.Add(curTaskBoardHistory);
            }
        }
예제 #3
0
        public async Task <IActionResult> DeleteProject(string id)
        {
            GoNorthProject project = await _projectDbAccess.GetProjectById(id);

            bool isProjectEmpty = await IsProjectEmpty(project);

            if (!isProjectEmpty)
            {
                _logger.LogInformation("Attempted to delete non empty project {0}.", project.Name);
                return(StatusCode((int)HttpStatusCode.BadRequest, _localizer["ProjectNotEmpty"].Value));
            }

            await _projectDbAccess.DeleteProject(project);

            _logger.LogInformation("Project was deleted.");

            await _timelineService.AddTimelineEntry(TimelineEvent.ProjectDeleted, project.Name);

            return(Ok(id));
        }
예제 #4
0
        /// <summary>
        /// Returns the current user project
        /// </summary>
        /// <returns>Current user project</returns>
        public async Task <GoNorthProject> GetUserProject()
        {
            string userId = _userManager.GetUserId(_httpContext.HttpContext.User);
            UserSelectedProject selectedProject = await _projectDbAccess.GetUserSelectedProject(userId);

            GoNorthProject project = null;

            if (selectedProject != null)
            {
                project = await _projectDbAccess.GetProjectById(selectedProject.ProjectId);
            }

            if (project == null)
            {
                project = await _projectDbAccess.GetDefaultProject();
            }

            return(project);
        }