コード例 #1
0
        public IResult <IEnumerable <ConsignmentShipfile> > SendEmails(
            ConsignmentShipfilesSendEmailsRequestResource toSend)
        {
            try
            {
                var result = this.domainService.SendEmails(
                    toSend.Shipfiles.Select(
                        s => new ConsignmentShipfile {
                    Id = s.Id, ConsignmentId = s.ConsignmentId
                }),
                    toSend.Test,
                    toSend.TestEmailAddress);

                if (!toSend.Test)
                {
                    this.transactionManager.Commit();
                }

                return(new SuccessResult <IEnumerable <ConsignmentShipfile> >(result));
            }
            catch (PdfServiceException exception)
            {
                return(new ServerFailureResult <IEnumerable <ConsignmentShipfile> >(exception.Message));
            }
        }
コード例 #2
0
        public void SetUp()
        {
            this.resource = new ConsignmentShipfilesSendEmailsRequestResource
            {
                Test      = false,
                Shipfiles = new List <ConsignmentShipfileResource>
                {
                    new ConsignmentShipfileResource
                    {
                        ConsignmentId = 1,
                    }
                }
            };

            this.result = new List <ConsignmentShipfile>
            {
                new ConsignmentShipfile
                {
                    ConsignmentId = 1,
                    Consignment   = new Consignment()
                }
            };

            this.ShipfileService.SendEmails(Arg.Any <ConsignmentShipfilesSendEmailsRequestResource>())
            .Returns(new SuccessResult <IEnumerable <ConsignmentShipfile> >(this.result));

            this.Response = this.Browser.Post(
                $"/logistics/shipfiles/send-emails",
                with =>
            {
                with.Header("Accept", "application/json");
                with.JsonBody(this.resource);
            }).Result;
        }