示例#1
0
        public async Task <IActionResult> Revisions(Guid id)
        {
            var projectUid = id;

            if (projectUid.IsEmptyGuid())
            {
                return(RedirectToHome());
            }

            var model = new ProjectRevisionReadListModel();

            if (projectUid.IsNotEmptyGuid())
            {
                var request  = new ProjectReadRequest(CurrentUser.Id, projectUid);
                var response = await _projectService.GetProject(request);

                if (response.Status.IsNotSuccess)
                {
                    return(NotFound());
                }

                model.ProjectUid  = projectUid;
                model.ProjectName = response.Item.Name;
                model.SetInputModelValues();
            }

            return(View(model));
        }
示例#2
0
        public static ProjectReadRequest GetProjectReadRequest()
        {
            var project = GetOrganizationOneProjectOne();
            var request = new ProjectReadRequest(CurrentUserId, project.Uid);

            return(request);
        }
示例#3
0
        public async Task <IActionResult> CreateBulkLabel(Guid id)
        {
            var projectUid = id;

            if (projectUid.IsEmptyGuid())
            {
                return(RedirectToAccessDenied());
            }

            var request = new ProjectReadRequest(CurrentUser.Id, projectUid);
            var project = await _projectService.GetProject(request);

            if (project.Status.IsNotSuccess)
            {
                return(RedirectToAccessDenied());
            }

            var model = LabelMapper.MapCreateBulkLabelModel(project.Item);

            return(View(model));
        }
示例#4
0
        public async Task <IActionResult> Detail(Guid id)
        {
            var projectUid = id;

            if (projectUid.IsEmptyGuid())
            {
                return(RedirectToAccessDenied());
            }

            var request  = new ProjectReadRequest(CurrentUser.Id, projectUid);
            var response = await _projectService.GetProject(request);

            if (response.Status.IsNotSuccess)
            {
                return(RedirectToAccessDenied());
            }

            var model = ProjectMapper.MapProjectDetailModel(response.Item);

            return(View(model));
        }
示例#5
0
        public async Task <ProjectReadResponse> GetProject(ProjectReadRequest request)
        {
            var response = new ProjectReadResponse();

            var currentUser = _cacheManager.GetCachedCurrentUser(request.CurrentUserId);

            var project = await _projectRepository.Select(x => x.Uid == request.ProjectUid);

            if (project.IsNotExist())
            {
                response.SetInvalidBecauseNotFound("project");
                return(response);
            }

            if (project.OrganizationId != currentUser.OrganizationId)
            {
                response.SetFailed();
                return(response);
            }

            response.Item   = _projectFactory.CreateDtoFromEntity(project);
            response.Status = ResponseStatus.Success;
            return(response);
        }