Exemple #1
0
        public async Task DontRegister(DontRegister parameters, EmailOrDataboxEnum type)
        {
            var emlNode = await _alfrescoHttpClient.GetNodeInfo(parameters.NodeId, ImmutableList <Parameter> .Empty
                                                                .Add(new Parameter(AlfrescoNames.Headers.Include, AlfrescoNames.Includes.Path, ParameterType.QueryString)));

            if (parameters.Body.Reason.Length < 4)
            {
                throw new BadRequestException(ErrorCodes.V_MIN_TEXT);
            }

            if (parameters.Body.Reason.Length > 30)
            {
                parameters.Body.Reason = parameters.Body.Reason.Substring(0, 30);
            }

            var body = new NodeBodyUpdate();
            var path = string.Empty;

            switch (type)
            {
            case EmailOrDataboxEnum.Email:

                if (emlNode?.Entry?.Path?.Name.StartsWith(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.MailRoomEmail, StringComparison.OrdinalIgnoreCase) == false)
                {
                    throw new BadRequestException("", "Node is not in Mailbox");
                }

                body = new NodeBodyUpdate
                {
                    Properties = new Dictionary <string, object>
                    {
                        { SpisumNames.Properties.EmailNotRegisteredReason, parameters.Body.Reason }
                    }
                };
                path = SpisumNames.Paths.MailRoomEmailNotRegistered;
                break;

            case EmailOrDataboxEnum.Databox:
                if (emlNode?.Entry?.Path?.Name.StartsWith(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.MailRoomDataBox, StringComparison.OrdinalIgnoreCase) == false)
                {
                    throw new BadRequestException("", "Node is not in Databox");
                }

                body = new NodeBodyUpdate
                {
                    Properties = new Dictionary <string, object>
                    {
                        { SpisumNames.Properties.DataBoxNotRegisteredReason, parameters.Body.Reason }
                    }
                };
                path = SpisumNames.Paths.MailRoomDataBoxNotRegistered;
                break;
            }

            await _alfrescoHttpClient.UpdateNode(parameters.NodeId, body);

            await _nodesService.MoveChildrenByPath(parameters.NodeId, path);
        }
Exemple #2
0
 public async Task DontRegister([FromRoute] DontRegister parameters)
 {
     await _emailDataBoxService.DontRegister(parameters, ClientSide.Enums.EmailOrDataboxEnum.Databox);
 }