コード例 #1
0
        public async Task <IActionResult> CreateLoad([FromBody] LoadDetailViewModel load)
        {
            try
            {
                var loadData = _mapper.Map <LoadDetailData>(load);

                /**
                 * DO NOT YET consider auto-posting via the v2 customer API
                 * [10:08 AM] Kind, Brian K.
                 *     Now I am questioning the true purpose of Auto Post To Marketplace.  Based on what you just gave me I am thinking the Auto Post to Marketplace was really for  the old way.
                 * ​[10:08 AM] Vetta, Joe (Consultant)
                 *     (laugh)
                 * ​[10:11 AM] Kind, Brian K.
                 *     How far are we in the rabbit hole are we in fixing the bug?  Can we leave the new way logic alone.  Knowing my scenario #2  is just the way it is for now.
                 * ​[10:11 AM] Vetta, Joe (Consultant)
                 *     Yes, it's a simple thing for me to undo
                 * ​[10:11 AM] Kind, Brian K.
                 *     So original issue was EDI (Old Way), shipper had Auto Post to marketplace set to 'N'.  We fixed it.
                 * ​[10:12 AM] Kind, Brian K.
                 *     I can reach out to Kevin and explain.  So basically new way does not care about Auto Post to marketplace for now.
                 * ​[10:13 AM] Kind, Brian K.
                 *     Old way will
                 */
                loadData.LoadTransaction = new LoadTransactionData()
                {
                    TransactionType = TransactionTypeData.PendingAdd
                };

                var result  = _loadService.GenerateReturnURL(new LoadDetailData[] { loadData });
                var options = new CreateLoadOptionsDto()
                {
                    ValidateAddress = OrderAddressValidationEnum.Validate,
                    ManuallyCreated = false
                };
                var createResponse = await _loadService.CreateLoad(loadData, customerId : _user.UserId.Value, username : _systemUser, options);

                if (!createResponse.IsSuccess)
                {
                    return(BadRequest(new ResponseMessage <string>(), createResponse.ModelState));
                }

                return(Success(result));
            }
            catch (ValidationException e)
            {
                return(Error <string>(e));
            }
        }