Beispiel #1
0
        public async Task <GenericResponse <decimal?> > GetSmartSpotQuoteAsync(RecaptchaRequest <LoadshopSmartSpotQuoteRequest> request)
        {
            await _recaptchaService.ValidateToken(request);

            AssertConfig();

            var response = new GenericResponse <decimal?>();
            var awsModel = await MapFromLoadshopSmartSpotQuoteRequest(request.Data, response);

            if (!response.IsSuccess)
            {
                return(response);
            }

            response.Data = await RequestQuoteFromAWS(awsModel);

            _db.Add(new SmartSpotPriceQuoteLogEntity
            {
                SmartSpotPriceQuoteLogId = Guid.NewGuid(),
                Miles          = awsModel.DirectMiles,
                Weight         = awsModel.Weight,
                EquipmentId    = awsModel.EquipmentId,
                OrigState      = awsModel.OrigState,
                Orig3Zip       = awsModel.O3Zip,
                DestState      = awsModel.DestState,
                Dest3Zip       = awsModel.D3Zip,
                PkupDate       = awsModel.PkupDate,
                SmartSpotPrice = response.Data ?? 0,
                UserId         = _userContext.UserId
            });
            await _db.SaveChangesAsync(_userContext.UserName);

            return(response);
        }