Example #1
0
        public async Task <IActionResult> PreviewUpdateLoad([FromBody] LoadDetailViewModel load)
        {
            try
            {
                var loadData = _mapper.Map <LoadDetailData>(load);
                loadData.LoadTransaction = new LoadTransactionData()
                {
                    TransactionType = TransactionTypeData.Updated
                };
                var updateOptions = new UpdateLoadOptions()
                {
                    MapObject                 = true,
                    ManuallyCreated           = false,
                    UpdateSpecialInstructions = false,
                    AppendComments            = true,  // overlay any comments
                    SaveChanges               = false, // ensure we don't apply the updates
                    IgnoreFuel                = true,
                    IgnoreLineHaulRate        = true,
                    AddSmartSpot              = false
                };

                var result = await _loadService.PreviewUpdateLoad(loadData, _user.UserId.Value, _systemUser, updateOptions);

                if (string.IsNullOrEmpty(result.ErrorMessage))
                {
                    return(Success(new CheckUpdateLoadStatusViewModel()
                    {
                        CanLoadRemainInLoadshop = result.LoadKeptInMarketplace
                    }));
                }

                throw new ValidationException(result.ErrorMessage);
            }
            catch (ValidationException e)
            {
                return(Error <LoadDetailViewModel>(e));
            }
        }