コード例 #1
0
        public async Task <IActionResult> CreateLoads([FromBody] LoadDetailViewModel[] loads)
        {
            try
            {
                /**
                 * 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
                 */
                var loadDetails = _mapper.Map <LoadDetailData[]>(loads);
                foreach (var load in loadDetails)
                {
                    if (load != null)
                    {
                        load.LoadTransaction = new LoadTransactionData()
                        {
                            TransactionType = TransactionTypeData.PendingAdd
                        };
                    }
                }

                var options = new CreateLoadOptionsDto()
                {
                    ValidateAddress = OrderAddressValidationEnum.Validate,
                    ManuallyCreated = false,
                    AddSmartSpot    = false,
                    OverrideLineHaulWithSmartSpot = false,
                    RemoveLineHaulRate            = true
                };
                var createResponse = await _loadService.CreateLoadsWithContinueOnFailure(loadDetails, _user.UserId.Value, _systemUser, options);

                var response = new ResponseMessage <string>();

                if (createResponse.Data.Any())
                {
                    var result = _loadService.GenerateReturnURL(createResponse.Data);
                    response.Data = result;
                }

                if (!createResponse.IsSuccess)
                {
                    return(BadRequest(response, createResponse.ModelState));
                }

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