public async Task <IActionResult> UpdateLoad([FromBody] LoadDetailViewModel load, [FromQuery] UpdateLoadOptionsViewModel options) { 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 loadData = _mapper.Map <LoadDetailData>(load); loadData.LoadTransaction = new LoadTransactionData() { TransactionType = TransactionTypeData.PendingUpdate }; var updateOptions = new UpdateLoadOptions() { MapObject = true, ValidateAddress = true, ManuallyCreated = false, UpdateSpecialInstructions = false, AppendComments = options?.AppendComments ?? false }; var result = _loadService.GenerateReturnURL(new LoadDetailData[] { loadData }); var updateResponse = await _loadService.UpdateLoad(loadData, _user.UserId.Value, _systemUser, updateOptions); if (!updateResponse.IsSuccess) { return(BadRequest(new ResponseMessage <string>(), updateResponse.ModelState)); } return(Success(result)); } catch (ValidationException e) { return(Error <string>(e)); } }
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)); } }
public async Task <IActionResult> UpdateLoad([FromBody] LoadDetailViewModel load, [FromQuery] bool ignoreFuel = false, [FromQuery] bool ignoreLineHaulRate = false, [FromQuery] bool useSmartSpotPricing = false) { try { var loadData = _mapper.Map <LoadDetailData>(load); var custIdentUserId = _user.UserId.Value; var autoPost = load.AutoPostLoad ?? _loadService.GetAutoPostToLoadshop(custIdentUserId); /** * Normal V1 behavior is to set the load to Updated, which means the load shows up on the Marketplace * immedaitely. For some reason TRS_Loadshop_LoadshopIntegrationService still calls this v1 end-point * when updating loads, even though we don't normally want loads to go directly to the marketplace, * now that shippers have a Post tab to work with directly in Loadshop. * * That means, we need to check the Shipper Profile before we update the load with an Updated transaction. * If the shipper's profile says to not auto post the load, then we should update the load with a * Pending Update transaction, which keeps the load on the Shipper's Post tab, and does not show it on the * Marketplace tab. * * The V2 UpdateLoad end-point automatically sets loads to Pending Update, so I'm not entirely sure why * we're still calling V1, so we may have to revist this and/or retire this end-point at some future date. */ if (autoPost) { loadData.LoadTransaction = new LoadTransactionData { TransactionType = TransactionTypeData.Updated }; /** * Even when the shipper profile says the load should AutoPost, we do not * allow that if the load does not have a line haul rate and the TOPS * LoadshopShipperMapping is set to not use SmartSpot pricing. */ if (loadData.LineHaulRate == 0m && !useSmartSpotPricing) { loadData.LoadTransaction = new LoadTransactionData { TransactionType = TransactionTypeData.PendingUpdate }; } } else { loadData.LoadTransaction = new LoadTransactionData { TransactionType = TransactionTypeData.PendingUpdate }; } var updateOptions = new UpdateLoadOptions() { MapObject = true, ManuallyCreated = false, UpdateSpecialInstructions = false, AppendComments = false, IgnoreLineHaulRate = ignoreLineHaulRate, IgnoreFuel = ignoreFuel, AddSmartSpot = useSmartSpotPricing, OverrideLineHaulWithSmartSpot = useSmartSpotPricing }; var result = await _loadService.UpdateLoad(loadData, _user.UserId.Value, _systemUser, updateOptions); if (result.IsSuccess) { return(Success(_mapper.Map <LoadDetailViewModel>(result.Data))); } throw new ValidationException(result.GetAllMessages()); } catch (ValidationException e) { return(Error <LoadDetailViewModel>(e)); } }
public async Task <IActionResult> UpdateLoad([FromBody] OrderEntryViewModel orderEntryVM) { try { if (!_userContext.UserId.HasValue) { throw new Exception("Invalid UserId"); } // LoadService.CreateLoad expects the Customer.IdentUserId, not the Customer.CustomerId var customerIdentUserId = await _userProfileService.GetPrimaryCustomerIdentUserId(_userContext.UserId.Value); if (!customerIdentUserId.HasValue) { throw new Exception("User does not have a primary customer."); } // Saving locations requires FK to CustomerID var customerId = await _userProfileService.GetPrimaryCustomerId(_userContext.UserId.Value); if (!customerId.HasValue) { throw new Exception("User does not have a primary customer."); } SetLoadStopDtTms(orderEntryVM); var load = _mapper.Map <LoadDetailData>(orderEntryVM); load.LoadTransaction = new LoadTransactionData() { TransactionType = TransactionTypeData.PendingAdd }; load.LoadStops = _loadService.SetApptTypeOnLoadStops(load.LoadStops); var updateOptions = new UpdateLoadOptions() { MapObject = true, ValidateAddress = true, ManuallyCreated = true }; var response = await _loadService.UpdateLoad(load, customerIdentUserId.Value, _userContext.UserName, updateOptions); if (!response.IsSuccess) { var problemDetails = new ValidationProblemDetails(response.ModelState) { Title = "Update Load Error", Detail = "One or more errors occurred when trying to save this load. See form for error details", Status = (int)HttpStatusCode.BadRequest, Instance = $"urn:kbxl:error:{Guid.NewGuid()}" }; return(BadRequest(problemDetails)); } else { SaveLocations(customerId.Value, load.LoadStops); } return(Success(orderEntryVM)); } catch (ValidationException exception) { return(Error <List <LocationViewModel> >(exception)); } }