コード例 #1
0
        public void DoesResourceTypeExist_EmptryResourceType_ReturnsFalse()
        {
            // Arrange
            var resourceType = "";

            // Act
            var result = EnumUtil.DoesResourceTypeExist(resourceType);

            // Assert
            Assert.False(result);
        }
コード例 #2
0
        public void DoesResourceTypeExist_ProjectResourceType_ReturnsTrue()
        {
            // Arrange
            var resourceType = ResourceTypeEnum.Project;

            // Act
            var result = EnumUtil.DoesResourceTypeExist(resourceType);

            // Assert
            Assert.True(result);
        }
コード例 #3
0
        public async Task <IActionResult> CreateMarkSession(
            string resourceType,
            string resourceId,
            [FromQuery(Name = "markSessionType")] string markSessionType,
            [FromQuery(Name = "projectId")] string projectId
            )
        {
            if (string.IsNullOrEmpty(resourceId))
            {
                return(BadRequest("resourceId is not specified!"));
            }

            if (!EnumUtil.DoesMarkSessionTypeExist(markSessionType))
            {
                return(BadRequest("markSessionType is not specified or the type is invalid!"));
            }

            if (string.IsNullOrEmpty(projectId))
            {
                if (resourceType == ResourceTypeEnum.Project)
                {
                    projectId = resourceId;
                }
                else
                {
                    return(BadRequest("projectId is not specified!"));
                }
            }

            if (!EnumUtil.DoesResourceTypeExist(resourceType))
            {
                return(BadRequest("resourceType is not specified or the type is invalid!"));
            }

            var createdMarkSessionModel = await _markSessionHandler.CreateMarkSession(
                resourceId,
                projectId,
                resourceType,
                markSessionType
                );

            return(Ok(
                       _mapper.Map <MarkSessionForReturnDto>(createdMarkSessionModel)
                       ));
        }
コード例 #4
0
        public async Task<IActionResult> DeleteResources(
            string resourceType,
            string resourceId,
            [FromQuery(Name = "projectId")] string projectId
        )
        {
            if (string.IsNullOrEmpty(resourceType))
            {
                return BadRequest("resourceType is not specified!");
            }

            if (string.IsNullOrEmpty(resourceId))
            {
                return BadRequest("resourceId is not specified!");
            }

            if (string.IsNullOrEmpty(projectId))
            {
                if (resourceType == ResourceTypeEnum.Project)
                {
                    projectId = resourceId;
                }
                else
                {
                    return BadRequest("projectId is not specified!");
                }
            }

            if (!EnumUtil.DoesResourceTypeExist(resourceType))
            {
                return BadRequest("resourceType is not specified or is invalid!");
            }

            var backgroundJobId = await _deleteControllerHandler.CreateMarkSessionAndDeleteDependantResurces(
                resourceType,
                resourceId,
                projectId
            );

            return Accepted(
                value: backgroundJobId
            );
        }