public IEnumerable<dynamic> Process(QuoteRequest quote_request)
        {
            var web_request = quote_web_request_builder.Build(quote_request);
            var web_response = web_request_processor.Process(web_request);

            return response_processor.Return(new QuoteResponse(web_response, quote_request));
        }
        public virtual string Build(QuoteRequest quote_request)
        {
            if (!quote_request.ReturnParameters.Any())
                return "";

            var url_return_parameters = quote_request.ReturnParameters.Select(x => return_parameter_map.Map(x));
            return url_return_parameters.Aggregate("f=", (url_parameter, quote_return_parameter) => url_parameter + quote_return_parameter);
        }
Ejemplo n.º 3
0
        public async Task<QuoteRequest> UpdateQuoteRequestAsync(QuoteRequest quoteRequestModel)
        {
            var quoteRequest = quoteRequestModel.ToServiceModel();

            if (quoteRequestModel.IsTransient)
            {
                quoteRequest = await _quoteClient.CreateAsync(quoteRequest);
                quoteRequestModel = quoteRequest.ToViewModel();
            }
            else
            {
                await _quoteClient.UpdateAsync(quoteRequest);
                quoteRequestModel = await GetCurrentQuoteRequestAsync(quoteRequest.StoreId, quoteRequest.CustomerId);
            }

            return quoteRequestModel;
        }
Ejemplo n.º 4
0
        public async Task UpdateAsync(QuoteRequest quoteRequest)
        {
            var requestUrl = CreateRequestUri(RelativePaths.QuoteRequests);

            await SendAsync <QuoteRequest, QuoteRequest>(requestUrl, HttpMethod.Put, quoteRequest).ConfigureAwait(false);
        }
Ejemplo n.º 5
0
        public async Task<QuoteRequest> RecalculateAsync(QuoteRequest quoteRequestModel)
        {
            var quoteRequest = quoteRequestModel.ToServiceModel();

            var apiResponse = await _quoteClient.RecalculateAsync(quoteRequest);

            if (apiResponse != null)
            {
                quoteRequestModel = apiResponse.ToViewModel();
            }

            return quoteRequestModel;
        }
Ejemplo n.º 6
0
 public virtual void onMessage(QuoteRequest message, QuickFix.SessionID session)
 {
     throw new QuickFix.UnsupportedMessageType();
 }
        public async Task <ActionResult <QuoteRequest> > Create([FromBody] QuoteRequest quoteRequest)
        {
            await _quoteRequestService.SaveChangesAsync(new[] { quoteRequest });

            return(Ok(quoteRequest));
        }
Ejemplo n.º 8
0
        public IQuoteRequestBuilder TakeQuoteRequest(QuoteRequest quoteRequest)
        {
            _quoteRequest = quoteRequest;

            return(this);
        }
Ejemplo n.º 9
0
        public IActionResult ProcessTemplate(QuoteTemplate quoteTemplate)
        {
            if (HttpContext.Session.Keys.All(x => x != Statics.EmailTempData))
            {
                return(RedirectToAction("Index", "Registration"));
            }

            QuoteRequest quoteRequest = null;

            if (!Request.Query.ContainsKey("quoteIdIdentity"))
            {
                string email = (HttpContext.Session.Keys.Contains(Statics.EmailTempData)
                    ? HttpContext.Session.GetString(Statics.EmailTempData)
                    : String.Empty);
                User    user    = _wrapper.CreateUser(email);
                Journey journey = _wrapper.GetJourney(email);

                var templateId = 0;
                if (Request.Method == "POST")
                {
                    int attendance = int.Parse(Request.Form["Attendees"]);
                    templateId   = int.Parse(Request.Form["TemplateId"]);
                    quoteRequest =
                        _wrapper.CreateRequestFromTemplate(templateId, user.Id, attendance, journey.EventDate);
                    return(View(quoteRequest));
                }

                if (!journey.QuoteIdIdentity.HasValue)
                {
                    if (journey.Completed.HasValue)
                    {
                        if (!HttpContext.Session.Keys.Contains(Statics.EmailTempData))
                        {
                            HttpContext.Session.SetString(Statics.EmailTempData, journey.Email);
                        }
                        return(RedirectToAction("Step3", "Registration"));
                    }
                }
                else
                {
                    templateId = journey.QuoteIdIdentity.Value;

                    if (Request.Method == "GET")
                    {
                        quoteRequest = _wrapper.LoadQuoteRequest(templateId);
                    }
                }
            }
            else
            {
                int id = int.Parse(Request.Query["quoteIdIdentity"]);
                quoteRequest = _wrapper.LoadQuoteRequest(id);
            }

            if (Request.Query.ContainsKey(Statics.ProcessingStatus))
            {
                quoteRequest.ProcessingResult  = Enum.Parse <ProcessingResult>(Request.Query[Statics.ProcessingStatus]);
                quoteRequest.ProcessingMessage = Request.Query[Statics.ProcessingMessage];
            }

            return(View(quoteRequest));
        }
Ejemplo n.º 10
0
 public async Task <IActionResult> GetQuote([FromBody] QuoteRequest request)
 {
     return(new OkObjectResult(await _wholesalerService.GenerateQuote(request)));
 }
Ejemplo n.º 11
0
        public ActionResult Index(QuoteRequest model)
        {
            model.SendEmail();

            return(View("Index"));
        }
        public QuoteRequestEntity FromModel(QuoteRequest _, PrimaryKeyResolvingMap pkMap)
        {
            if (_ == null)
            {
                throw new ArgumentNullException(nameof(_));
            }

            pkMap.AddPair(_, this);

            var target = this;

            target.Id           = _.Id;
            target.CreatedBy    = _.CreatedBy;
            target.CreatedDate  = _.CreatedDate;
            target.ModifiedBy   = _.ModifiedBy;
            target.ModifiedDate = _.ModifiedDate;

            target.Number             = _.Number;
            target.StoreId            = _.StoreId;
            target.ChannelId          = _.ChannelId;
            target.IsAnonymous        = _.IsAnonymous;
            target.CustomerId         = _.CustomerId;
            target.CustomerName       = _.CustomerName;
            target.OrganizationName   = _.OrganizationName;
            target.OrganizationId     = _.OrganizationId;
            target.EmployeeId         = _.EmployeeId;
            target.EmployeeName       = _.EmployeeName;
            target.ExpirationDate     = _.ExpirationDate;
            target.ReminderDate       = _.ReminderDate;
            target.EnableNotification = _.EnableNotification;
            target.IsLocked           = _.IsLocked;
            target.Status             = _.Status;
            target.Tag                     = _.Tag;
            target.Comment                 = _.Comment;
            target.InnerComment            = _.InnerComment;
            target.Currency                = _.Currency;
            target.Coupon                  = _.Coupon;
            target.ManualShippingTotal     = _.ManualShippingTotal;
            target.ManualSubTotal          = _.ManualSubTotal;
            target.ManualRelDiscountAmount = _.ManualRelDiscountAmount;
            target.LanguageCode            = _.LanguageCode;
            target.IsCancelled             = _.IsCancelled;
            target.CancelledDate           = _.CancelledDate;
            target.CancelReason            = _.CancelReason;

            // target. QuoteRequestTotals Totals     =               ;

            if (_.ShipmentMethod != null)
            {
                ShipmentMethodCode   = _.ShipmentMethod.ShipmentMethodCode;
                ShipmentMethodOption = _.ShipmentMethod.OptionName;
            }
            if (_.Addresses != null)
            {
                Addresses = new ObservableCollection <AddressEntity>(_.Addresses.Select(x => AbstractTypeFactory <AddressEntity> .TryCreateInstance().FromModel(x)));
            }
            if (_.Attachments != null)
            {
                Attachments = new ObservableCollection <AttachmentEntity>(_.Attachments.Select(x => AbstractTypeFactory <AttachmentEntity> .TryCreateInstance().FromModel(x)));
            }
            if (_.Items != null)
            {
                Items = new ObservableCollection <QuoteItemEntity>(_.Items.Select(x => AbstractTypeFactory <QuoteItemEntity> .TryCreateInstance().FromModel(x, pkMap)));
            }
            if (_.DynamicProperties != null)
            {
                DynamicPropertyObjectValues = new ObservableCollection <QuoteDynamicPropertyObjectValueEntity>(_.DynamicProperties.SelectMany(p => p.Values
                                                                                                                                              .Select(v => AbstractTypeFactory <QuoteDynamicPropertyObjectValueEntity> .TryCreateInstance().FromModel(v, _, p))).OfType <QuoteDynamicPropertyObjectValueEntity>());
            }
            return(this);
        }
Ejemplo n.º 13
0
 public QuoteRequestChangeEvent(EntryState state, QuoteRequest origQuote, QuoteRequest modifiedQuote)
 {
     ChangeState   = state;
     OrigQuote     = origQuote;
     ModifiedQuote = modifiedQuote;
 }
        public virtual QuoteRequest ToModel(QuoteRequest target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            var _ = this;

            target.Id           = _.Id;
            target.CreatedBy    = _.CreatedBy;
            target.CreatedDate  = _.CreatedDate;
            target.ModifiedBy   = _.ModifiedBy;
            target.ModifiedDate = _.ModifiedDate;

            target.Number             = _.Number;
            target.StoreId            = _.StoreId;
            target.ChannelId          = _.ChannelId;
            target.IsAnonymous        = _.IsAnonymous;
            target.CustomerId         = _.CustomerId;
            target.CustomerName       = _.CustomerName;
            target.OrganizationName   = _.OrganizationName;
            target.OrganizationId     = _.OrganizationId;
            target.EmployeeId         = _.EmployeeId;
            target.EmployeeName       = _.EmployeeName;
            target.ExpirationDate     = _.ExpirationDate;
            target.ReminderDate       = _.ReminderDate;
            target.EnableNotification = _.EnableNotification;
            target.IsLocked           = _.IsLocked;
            target.Status             = _.Status;
            target.Tag                     = _.Tag;
            target.Comment                 = _.Comment;
            target.InnerComment            = _.InnerComment;
            target.Currency                = _.Currency;
            target.Coupon                  = _.Coupon;
            target.ManualShippingTotal     = _.ManualShippingTotal;
            target.ManualSubTotal          = _.ManualSubTotal;
            target.ManualRelDiscountAmount = _.ManualRelDiscountAmount;
            target.LanguageCode            = _.LanguageCode;
            target.IsCancelled             = _.IsCancelled;
            target.CancelledDate           = _.CancelledDate;
            target.CancelReason            = _.CancelReason;

            // target.Totals     = default(QuoteRequestTotals)               ;

            if (ShipmentMethodCode != null)
            {
                target.ShipmentMethod = new ShipmentMethod
                {
                    OptionName         = ShipmentMethodOption,
                    ShipmentMethodCode = ShipmentMethodCode
                };
            }
            target.Addresses         = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList();
            target.Attachments       = Attachments.Select(x => x.ToModel(AbstractTypeFactory <QuoteAttachment> .TryCreateInstance())).ToList();
            target.Items             = Items.Select(x => x.ToModel(AbstractTypeFactory <QuoteItem> .TryCreateInstance())).ToList();
            target.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            return(target);
        }
 public QuoteRequestUpdatedEvent(QuoteRequest quoteRequest)
 {
     QuoteRequest = quoteRequest;
 }
Ejemplo n.º 16
0
        public async Task <ActionResult> Submit(QuoteRequest model)
        {
            if (User.Identity.IsAuthenticated && string.IsNullOrEmpty(model.Email))
            {
                return(Json(new { errorMessage = "Field \"Email\" is required" }));
            }
            if (model.BillingAddress != null)
            {
                if (model.BillingAddressErrors.Count > 0)
                {
                    var firstError = model.BillingAddressErrors.First();
                    return(Json(new { errorMessage = firstError }));
                }
            }
            if (model.ShippingAddress != null)
            {
                if (model.ShippingAddressErrors.Count > 0)
                {
                    var firstError = model.ShippingAddressErrors.First();
                    return(Json(new { errorMessage = firstError }));
                }
            }
            Context.ActualQuoteRequest.CustomerId      = Context.CustomerId;
            Context.ActualQuoteRequest.CustomerName    = Context.Customer.Name;
            Context.ActualQuoteRequest.Comment         = model.Comment;
            Context.ActualQuoteRequest.Email           = model.Email;
            Context.ActualQuoteRequest.BillingAddress  = model.BillingAddress;
            Context.ActualQuoteRequest.ShippingAddress = model.ShippingAddress;

            foreach (var quoteItem in model.Items)
            {
                var existingQuoteItem = Context.ActualQuoteRequest.Items.FirstOrDefault(i => i.Id == quoteItem.Id);

                existingQuoteItem.Comment = quoteItem.Comment;

                existingQuoteItem.ProposalPrices = new List <TierPrice>();
                foreach (var tearPrice in quoteItem.ProposalPrices)
                {
                    existingQuoteItem.ProposalPrices.Add(new TierPrice
                    {
                        Quantity = tearPrice.Quantity,
                        Price    = existingQuoteItem.SalePrice == 0 ? existingQuoteItem.ListPrice : existingQuoteItem.SalePrice
                    });
                }
            }

            if (!Context.ActualQuoteRequest.ProposalPricesUnique)
            {
                return(Json(new { errorMessage = "Proposal prices quantities must be unique." }));
            }

            if (User.Identity.IsAuthenticated)
            {
                Context.ActualQuoteRequest.Tag = null;
            }

            Context.ActualQuoteRequest.Status = "Processing";

            await QuoteService.UpdateQuoteRequestAsync(Context.ActualQuoteRequest);

            if (!User.Identity.IsAuthenticated)
            {
                string returnUrl = VirtualPathUtility.ToAbsolute("~/quote");
                return(Json(new { redirectUrl = VirtualPathUtility.ToAbsolute("~/account/login?returnUrl=" + returnUrl) }));
            }

            return(Json(new { redirectUrl = VirtualPathUtility.ToAbsolute("~/account/quote/" + Context.ActualQuoteRequest.Number) }));
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Get the email subject for the quote
 /// </summary>
 /// <param name="quoteRequest"></param>
 /// <returns></returns>
 private string GetEmailSubject(QuoteRequest quoteRequest)
 {
     return($"Docket Book Quote : {quoteRequest.Contact.Name}");
 }
Ejemplo n.º 18
0
 public void SaveQuoteRequest(QuoteRequest quoteRequest)
 {
     firebase.Child("QuoteRequest").PostAsync(quoteRequest);
 }
Ejemplo n.º 19
0
        public ActionResult Index()
        {
            var model = new QuoteRequest();

            return(View("Index", model));
        }
 public QuoteResponse(WebResponse web_response, QuoteRequest quote_request)
 {
     WebResponse  = web_response;
     QuoteRequest = quote_request;
 }
Ejemplo n.º 21
0
        public virtual async Task <ICartBuilder> FillFromQuoteRequest(QuoteRequest quoteRequest)
        {
            var productIds = quoteRequest.Items.Select(i => i.ProductId);
            var products   = await _catalogSearchService.GetProductsAsync(productIds.ToArray(), ItemResponseGroup.ItemLarge);

            _cart.Items.Clear();
            foreach (var product in products)
            {
                var quoteItem = quoteRequest.Items.FirstOrDefault(i => i.ProductId == product.Id);
                if (quoteItem != null)
                {
                    var lineItem = product.ToLineItem(_cart.Language, (int)quoteItem.SelectedTierPrice.Quantity);
                    lineItem.ListPrice = quoteItem.SelectedTierPrice.Price;
                    lineItem.SalePrice = quoteItem.SelectedTierPrice.Price;

                    AddLineItem(lineItem);
                }
            }

            if (quoteRequest.RequestShippingQuote)
            {
                _cart.Shipments.Clear();
                var shipment = new Shipment(_cart.Currency);

                foreach (var item in _cart.Items)
                {
                    shipment.Items.Add(item.ToShipmentItem());
                }

                if (quoteRequest.ShippingAddress != null)
                {
                    shipment.DeliveryAddress = quoteRequest.ShippingAddress;
                }

                if (quoteRequest.ShipmentMethod != null)
                {
                    var availableShippingMethods = await GetAvailableShippingMethodsAsync();

                    if (availableShippingMethods != null)
                    {
                        var availableShippingMethod = availableShippingMethods.FirstOrDefault(sm => sm.ShipmentMethodCode == quoteRequest.ShipmentMethod.ShipmentMethodCode);
                        if (availableShippingMethod != null)
                        {
                            shipment = quoteRequest.ShipmentMethod.ToShipmentModel(_cart.Currency);
                        }
                    }
                }

                _cart.Shipments.Add(shipment);
            }

            _cart.Payments.Clear();
            var payment = new Payment(_cart.Currency);

            if (quoteRequest.BillingAddress != null)
            {
                payment.BillingAddress = quoteRequest.BillingAddress;
            }

            payment.Amount = quoteRequest.Totals.GrandTotalInclTax;

            _cart.Payments.Add(payment);

            return(this);
        }
Ejemplo n.º 22
0
 public void LocalInit()
 {
     quoteRequest = Api.QuoteRequest; // Api is declared on TestBase
 }
Ejemplo n.º 23
0
        public async Task <QuoteResponse> CalculateQuote(QuoteRequest quoteParamters)
        {
            // Comma separated list of insureds’ ages.
            List <int> ageCollection = new List <int>();

            try
            {
                ageCollection = quoteParamters.Age.Split(',')
                                .Select(m => int.Parse(m))
                                .ToList();

                // Validation
                if (ageCollection.Count == 0)
                {
                    throw new ArgumentException("At least one value is required.");
                }
                if (ageCollection.First() < 18)
                {
                    throw new ArgumentException("First Age value must be 18 or over.");
                }
                if (ageCollection.Any(val => val < 1))
                {
                    throw new ArgumentException("0 and negative numbers are not a valid age.");
                }

                // Trip length is inclusive of both start date and end date so a start date of 2020-10-01 and an
                // end date of 2020-10-30 will constitute a trip length of 30 days.
                if (quoteParamters.Start_Date > quoteParamters.End_Date)
                {
                    throw new ArgumentException("Start Date can not be after End Date.");
                }

                // Find Date Diff.
                // Start Date and End Date are equal, assuming that is 1 day as someone may travel for just a single day.
                var days = quoteParamters.Start_Date == quoteParamters.End_Date ? 1 : ((quoteParamters.End_Date - quoteParamters.Start_Date).Days + 1);

                // Run calculation
                decimal       total     = 0.00M;
                const decimal fixedRate = 3.0M;
                decimal       ageLoad   = 0.0M;
                foreach (int age in ageCollection)
                {
                    // Find age load.
                    if (age >= 18 && age <= 30)
                    {
                        ageLoad = .6M;
                    }
                    else if (age >= 31 && age <= 40)
                    {
                        ageLoad = .7m;
                    }
                    else if (age >= 41 && age <= 50)
                    {
                        ageLoad = .8m;
                    }
                    else if (age >= 51 && age <= 60)
                    {
                        ageLoad = .9m;
                    }
                    else if (age >= 61 && age <= 70)
                    {
                        ageLoad = 1m;
                    }
                    else
                    {
                        throw new ArgumentException("Age exceeds 70");
                    }

                    total += fixedRate * ageLoad * days;
                }

                return(new QuoteResponse()
                {
                    Currency_Id = quoteParamters.Currency_Id, Quotation_Id = new Random().Next(1, 9999999).ToString(), Total = total
                });
            }
            catch (ArgumentException ex)
            {
                throw;
            }
            catch (FormatException ex)
            {
                throw new FormatException("An age must be a valid integer value.", ex);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 24
0
        public virtual QuoteRequest ToLiquidQuoteRequest(Storefront.Model.Quote.QuoteRequest quoteRequest)
        {
            var result = new QuoteRequest();

            result.CancelledDate      = quoteRequest.CancelledDate;
            result.CancelReason       = quoteRequest.CancelReason;
            result.ChannelId          = quoteRequest.ChannelId;
            result.Comment            = quoteRequest.Comment;
            result.CreatedBy          = quoteRequest.CreatedBy;
            result.CreatedDate        = quoteRequest.CreatedDate;
            result.CustomerId         = quoteRequest.CustomerId;
            result.CustomerName       = quoteRequest.CustomerName;
            result.EmployeeId         = quoteRequest.EmployeeId;
            result.EmployeeName       = quoteRequest.EmployeeName;
            result.EnableNotification = quoteRequest.EnableNotification;
            result.ExpirationDate     = quoteRequest.ExpirationDate;
            result.Id               = quoteRequest.Id;
            result.IsAnonymous      = quoteRequest.IsAnonymous;
            result.IsCancelled      = quoteRequest.IsCancelled;
            result.IsLocked         = quoteRequest.IsLocked;
            result.ModifiedBy       = quoteRequest.ModifiedBy;
            result.ModifiedDate     = quoteRequest.ModifiedDate;
            result.Number           = quoteRequest.Number;
            result.ObjectType       = quoteRequest.ObjectType;
            result.OrganizationId   = quoteRequest.OrganizationId;
            result.OrganizationName = quoteRequest.OrganizationName;
            result.ReminderDate     = quoteRequest.ReminderDate;
            result.Status           = quoteRequest.Status;
            result.StoreId          = quoteRequest.StoreId;

            result.Addresses = new List <Address>();
            foreach (var address in quoteRequest.Addresses)
            {
                result.Addresses.Add(ToLiquidAddress(address));
            }

            result.Attachments = new List <Attachment>();
            foreach (var attachment in quoteRequest.Attachments)
            {
                result.Attachments.Add(ToLiquidAttachment(attachment));
            }

            if (quoteRequest.Coupon != null)
            {
                result.Coupon = quoteRequest.Coupon.Code;
            }

            result.Currency = ToLiquidCurrency(quoteRequest.Currency);

            result.Items = new List <QuoteItem>();
            foreach (var quoteItem in quoteRequest.Items)
            {
                result.Items.Add(ToLiquidQuoteItem(quoteItem));
            }

            result.Language = ToLiquidLanguage(quoteRequest.Language);
            result.ManualRelDiscountAmount = quoteRequest.ManualRelDiscountAmount.Amount;
            result.ManualShippingTotal     = quoteRequest.ManualShippingTotal.Amount;
            result.ManualSubTotal          = quoteRequest.ManualSubTotal.Amount;

            if (quoteRequest.ShipmentMethod != null)
            {
                result.ShipmentMethod = ToLiquidShippingMethod(quoteRequest.ShipmentMethod);
            }

            result.TaxDetails = new List <TaxLine>();
            foreach (var taxDetail in quoteRequest.TaxDetails)
            {
                result.TaxDetails.Add(ToLiquidTaxLine(taxDetail));
            }

            if (quoteRequest.Totals != null)
            {
                result.Totals = ToLiquidRequestTotal(quoteRequest.Totals);
            }

            return(result);
        }
Ejemplo n.º 25
0
        public virtual async Task FillFromQuoteRequestAsync(QuoteRequest quoteRequest)
        {
            EnsureCartExists();

            var productIds = quoteRequest.Items.Select(i => i.ProductId);
            var products   = await _catalogService.GetProductsAsync(productIds.ToArray(), ItemResponseGroup.ItemLarge);

            Cart.Items.Clear();
            foreach (var product in products)
            {
                var quoteItem = quoteRequest.Items.FirstOrDefault(i => i.ProductId == product.Id);
                if (quoteItem != null)
                {
                    var lineItem = product.ToLineItem(Cart.Language, (int)quoteItem.SelectedTierPrice.Quantity);
                    lineItem.Product   = product;
                    lineItem.ListPrice = quoteItem.ListPrice;
                    lineItem.SalePrice = quoteItem.SelectedTierPrice.Price;
                    if (lineItem.ListPrice < lineItem.SalePrice)
                    {
                        lineItem.ListPrice = lineItem.SalePrice;
                    }
                    lineItem.DiscountAmount = lineItem.ListPrice - lineItem.SalePrice;
                    lineItem.IsReadOnly     = true;
                    lineItem.Id             = null;
                    Cart.Items.Add(lineItem);
                }
            }

            if (quoteRequest.RequestShippingQuote)
            {
                Cart.Shipments.Clear();
                var shipment = new Shipment(Cart.Currency);

                if (quoteRequest.ShippingAddress != null)
                {
                    shipment.DeliveryAddress = quoteRequest.ShippingAddress;
                }

                if (quoteRequest.ShipmentMethod != null)
                {
                    var availableShippingMethods = await GetAvailableShippingMethodsAsync();

                    var availableShippingMethod = availableShippingMethods?.FirstOrDefault(sm => sm.ShipmentMethodCode == quoteRequest.ShipmentMethod.ShipmentMethodCode);

                    if (availableShippingMethod != null)
                    {
                        shipment = quoteRequest.ShipmentMethod.ToCartShipment(Cart.Currency);
                    }
                }
                Cart.Shipments.Add(shipment);
            }

            var payment = new Payment(Cart.Currency)
            {
                Amount = quoteRequest.Totals.GrandTotalInclTax
            };

            if (quoteRequest.BillingAddress != null)
            {
                payment.BillingAddress = quoteRequest.BillingAddress;
            }

            Cart.Payments.Clear();
            Cart.Payments.Add(payment);
        }
Ejemplo n.º 26
0
 public async Task ValidateQuoteRequest(QuoteRequest request)
 {
     ValidateQuoteRequestNotEmpty(request);
     ValidateQuoteRequestAllUnique(request);
     await ValidateWholesalerStockForRequest(request);
 }
        public async Task <ActionResult <QuoteRequest> > CalculateTotals([FromBody] QuoteRequest quoteRequest)
        {
            quoteRequest.Totals = await _totalsCalculator.CalculateTotalsAsync(quoteRequest);

            return(Ok(quoteRequest));
        }
Ejemplo n.º 28
0
        public virtual QuoteRequest ToQuoteRequest(quoteDto.QuoteRequest quoteRequestDto, Currency currency, Language language)
        {
            var result = new QuoteRequest(currency, language)
            {
                CancelledDate      = quoteRequestDto.CancelledDate,
                CancelReason       = quoteRequestDto.CancelReason,
                ChannelId          = quoteRequestDto.ChannelId,
                Comment            = quoteRequestDto.Comment,
                CreatedBy          = quoteRequestDto.CreatedBy,
                CreatedDate        = quoteRequestDto.CreatedDate,
                CustomerId         = quoteRequestDto.CustomerId,
                CustomerName       = quoteRequestDto.CustomerName,
                EmployeeId         = quoteRequestDto.EmployeeId,
                EmployeeName       = quoteRequestDto.EmployeeName,
                EnableNotification = quoteRequestDto.EnableNotification ?? false,
                ExpirationDate     = quoteRequestDto.ExpirationDate,
                Id               = quoteRequestDto.Id,
                IsAnonymous      = quoteRequestDto.IsAnonymous ?? false,
                IsCancelled      = quoteRequestDto.IsCancelled ?? false,
                IsLocked         = quoteRequestDto.IsLocked ?? false,
                ModifiedBy       = quoteRequestDto.ModifiedBy,
                ModifiedDate     = quoteRequestDto.ModifiedDate,
                Number           = quoteRequestDto.Number,
                OrganizationId   = quoteRequestDto.OrganizationId,
                OrganizationName = quoteRequestDto.OrganizationName,
                ReminderDate     = quoteRequestDto.ReminderDate,
                Status           = quoteRequestDto.Status,
                StoreId          = quoteRequestDto.StoreId,
                Tag              = quoteRequestDto.Tag,

                Currency = currency,
                Language = language,
                ManualRelDiscountAmount = new Money(quoteRequestDto.ManualRelDiscountAmount ?? 0, currency),
                ManualShippingTotal     = new Money(quoteRequestDto.ManualShippingTotal ?? 0, currency),
                ManualSubTotal          = new Money(quoteRequestDto.ManualSubTotal ?? 0, currency)
            };

            if (quoteRequestDto.Addresses != null)
            {
                result.Addresses = quoteRequestDto.Addresses.Select(a => ToAddress(a)).ToList();
            }

            if (quoteRequestDto.Attachments != null)
            {
                result.Attachments = quoteRequestDto.Attachments.Select(a => ToAttachment(a)).ToList();
            }

            if (!string.IsNullOrEmpty(quoteRequestDto.Coupon))
            {
                result.Coupon = new Coupon {
                    AppliedSuccessfully = true, Code = quoteRequestDto.Coupon
                };
            }

            if (quoteRequestDto.DynamicProperties != null)
            {
                result.DynamicProperties = quoteRequestDto.DynamicProperties.Select(ToDynamicProperty).ToList();
            }

            if (quoteRequestDto.Items != null)
            {
                result.Items = quoteRequestDto.Items.Select(i => ToQuoteItem(i, currency)).ToList();
            }

            // TODO
            if (quoteRequestDto.ShipmentMethod != null)
            {
            }

            if (quoteRequestDto.TaxDetails != null)
            {
                result.TaxDetails = quoteRequestDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }

            if (quoteRequestDto.Totals != null)
            {
                result.Totals = ToQuoteTotals(quoteRequestDto.Totals, currency);
            }

            return(result);
        }
        public async Task <ActionResult> Update([FromBody] QuoteRequest quoteRequest)
        {
            await _quoteRequestService.SaveChangesAsync(new[] { quoteRequest });

            return(NoContent());
        }
Ejemplo n.º 30
0
 public void setObjects(QuoteRequest objects)
 {
     this.objects = objects;
 }
Ejemplo n.º 31
0
        public ProcessedQuote ProcessQuote(double totalFilimentUsed, double totalPrintTime, QuoteRequest quote)
        {
            ProcessedQuote processedQuote = new ProcessedQuote();

            processedQuote.TotalFilimentUsed = totalFilimentUsed;
            processedQuote.TotalPrintTime    = totalPrintTime;

            processedQuote.PrinterTimeCost = (totalPrintTime / 60) * _printOptionsAccessor.Value.PrinterTimeCost;

            var costperkilo = _printOptionsAccessor.Value.Materials[0].CostPerGram * 1000;
            var costpermm   = costperkilo / (330 * 1000);

            processedQuote.MaterialCost = totalFilimentUsed * costpermm;

            processedQuote.FixedCost = _printOptionsAccessor.Value.FixedCosts.Consumables + _printOptionsAccessor.Value.FixedCosts.Electricity + _printOptionsAccessor.Value.FixedCosts.PrinterDepreciation;
            processedQuote.TimeCost  = ((_printOptionsAccessor.Value.Timing.JobEnd + _printOptionsAccessor.Value.Timing.JobStart + _printOptionsAccessor.Value.Timing.ModelPrep + _printOptionsAccessor.Value.Timing.PostProcessing + _printOptionsAccessor.Value.Timing.PrinterPrep + _printOptionsAccessor.Value.Timing.Slicing + _printOptionsAccessor.Value.Timing.SupportRemoval) * _printOptionsAccessor.Value.Timing.CostPerMin);

            processedQuote.BaseTotal = processedQuote.PrinterTimeCost + processedQuote.MaterialCost + processedQuote.FixedCost + processedQuote.TimeCost;
            var failureCost = processedQuote.BaseTotal * _printOptionsAccessor.Value.CostAdjustments.FailureRate;
            var markup      = processedQuote.BaseTotal * _printOptionsAccessor.Value.CostAdjustments.Markup;

            processedQuote.QuoteTotal = processedQuote.BaseTotal + failureCost + markup;

            return(processedQuote);
        }
Ejemplo n.º 32
0
        static async Task Main(string[] args)
        {
            var username          = "******";
            var password          = "******";
            var loginURL          = "https://sandbox-api-applet.shipprimus.com/api/v1/login";
            var quoteURL          = "https://sandbox-api-applet.shipprimus.com/applet/v1/rate/multiple";
            var quoteSaveURL      = "https://sandbox-api-applet.shipprimus.com/applet/v1/rate/save";
            var createShipmentUrl = "https://sandbox-api-applet.shipprimus.com/applet/v1/book";

            Console.WriteLine("Get Token");
            var token = await QuoteHelper.GetBearerTokenPostAsync(username, password, loginURL);

            Console.WriteLine("Get Quotes");
            var quoteRequest = new QuoteRequest()
            {
                originCity         = "Miami",
                originState        = "FL",
                originZipcode      = "33142",
                originCountry      = "US",
                destinationCity    = "Laredo",
                destinationState   = "TX",
                destinationZipcode = "78045",
                destinationCountry = "US",
                uOM          = "US",
                pickupDate   = "06/30/2020",
                equipment    = "Van",
                Accessorials = new List <string>()
                {
                    "LFO", "INO", "LFD", "IND"
                },
                freightInfo = JArray.Parse("[{'qty':3,'weight':500,'weightType':'each','length':40,'width':48,'height':48,'class':50,'hazmat':0,'commodity':'','dimType':'PLT','stack':false}]")
            };
            var quote = await QuoteHelper.GetQuotes(quoteRequest, token, quoteURL);

            foreach (var item in quote.data.results.rates)
            {
                Console.WriteLine("id: " + item.id);
                Console.WriteLine("name: " + item.name);
                Console.WriteLine("SCAC: " + item.SCAC);
                Console.WriteLine("serviceLevel: " + item.serviceLevel);
                Console.WriteLine("serviceLevelCode: " + item.serviceLevelCode);
                Console.WriteLine("transitDays: " + item.transitDays);
                Console.WriteLine("total: " + item.total);
                Console.WriteLine("rateType: " + item.rateType);
                Console.WriteLine("iconUrl: " + item.iconUrl);
                Console.WriteLine("responseTime: " + item.responseTime);
                Console.WriteLine("vendorId: " + item.vendorId);
                foreach (var item1 in item.rateBreakdown)
                {
                    Console.WriteLine("Breakdown  =>>>  " + item1.name + ":" + item1.total);
                }
                Console.WriteLine("--------------------------------------------------------------------------------");
            }

            Console.WriteLine("Save Quotes");
            var quoteSaveRequest = new SaveQuoteRequest()
            {
                rateId = quote.data.results.rates[0].id,
                originShippingLocationId      = 0,
                destinationShippingLocationId = 0,
                laneDistance = 0,
            };
            JObject jrequestsavequote = JObject.FromObject(quoteSaveRequest);
            var     quoteSave         = QuoteHelper.SaveQuote(quoteSaveURL, token, jrequestsavequote);

            Console.WriteLine("Create Shipment");
            var createShipmentRequest = new CreateShipmentRequest()
            {
                thirdPartyReferenceNumber = "",
                PRONmbr   = "",
                BOLNmbr   = "testmehmet12345",
                BOLPrefix = "",
                shipper   = new Location()
                {
                    id              = 0,
                    name            = "string",
                    referenceNumber = "1515154",
                    address1        = "string",
                    address2        = "string",
                    city            = "Miami",
                    state           = "FL",
                    zipCode         = "33142",
                    country         = "US",
                    phone           = "string",
                    fax             = "string",
                    email           = "string",
                    contact         = "string",
                    contactPhone    = "string"
                },
                consignee = new Location()
                {
                    id              = 0,
                    name            = "string",
                    referenceNumber = "25551",
                    address1        = "string",
                    address2        = "string",
                    city            = "Laredo",
                    state           = "TX",
                    zipCode         = "78045",
                    country         = "US",
                    phone           = "string",
                    fax             = "string",
                    email           = "string",
                    contact         = "string",
                    contactPhone    = "string"
                },
                quoteNumber      = quoteSave.data != null ? quoteSave.data.results.quoteNumber:"",
                lineItems        = JArray.Parse("[{'qty':3,'weight':500,'weightType':'each','length':40,'width':48,'height':48,'volume': 200,'dimType':'PLT','class':'50','hazmat':0,'stack':false,'stackAmount': 1,'commodity':''}]"),
                UOM              = "US",
                accessorialsList = new List <string>()
                {
                    "LFO", "LFO"
                },
                insuranceAmount   = 0,
                insuranceFreight  = true,
                insuranceAddOn    = true,
                brokerInformation = new BrokerInformation()
                {
                    name    = "",
                    contact = "",
                    phone   = "",
                    notes   = ""
                },
                pickupInformation = new LocationInformation()
                {
                    date     = "2020-07-07",
                    type     = "PO",
                    fromTime = "08:30",
                    toTime   = "10:30"
                },
                deliveryInformation = new LocationInformation()
                {
                    date     = "2020-07-09",
                    type     = "DO",
                    fromTime = "08:30",
                    toTime   = "12:30"
                },
                BOLInstructions = "",
                shipmentNotes   = ""
            };
            JObject jrequestcreateshipment = JObject.FromObject(createShipmentRequest);
            var     quoteCreateShipment    = QuoteHelper.CreateShipment(createShipmentUrl, token, jrequestcreateshipment);
        }
Ejemplo n.º 33
0
 public static quoteDto.QuoteRequest ToQuoteRequestDto(this QuoteRequest quoteRequest)
 {
     return(QuoteConverterInstance.ToQuoteRequestDto(quoteRequest));
 }
Ejemplo n.º 34
0
        static async Task Main(string[] args)
        {
            try
            {
                var requestSerializer  = new XmlSerializer(typeof(QuoteRequest));
                var responseSerializer = new XmlSerializer(typeof(QuoteResponse));
                var port     = 3000;
                var address  = IPAddress.Parse("127.0.0.1");
                var listener = new TcpListener(address, port);
                listener.Start();

                bool Accepting = true;
                while (Accepting)
                {
                    TcpClient Client = listener.AcceptTcpClient();
#pragma warning disable CS4014
                    Task.Run(async() =>
                    {
                        using (NetworkStream ClientStream = Client.GetStream())
                        {
                            QuoteRequest APIRequest = (QuoteRequest)requestSerializer.Deserialize(ClientStream);

                            int interval = APIRequest.Interval;
                            SendData:

                            var APIResponse             = Stocks.Api.FetchQuotes(APIRequest).Result;
                            QuoteResponse serveResponse = new QuoteResponse();
                            int index = 0;
                            foreach (var i in APIResponse)
                            {
                                serveResponse.Quote.Add(new Quote());
                                serveResponse.Quote[index].symbol = i.Symbol;

                                foreach (var j in APIRequest.Fields)
                                {
                                    if (j == QuoteField.Open)
                                    {
                                        serveResponse.Quote[index].open = i.Open;
                                    }
                                    else if (j == QuoteField.Close)
                                    {
                                        serveResponse.Quote[index].close = i.Close;
                                    }
                                    else if (j == QuoteField.High)
                                    {
                                        serveResponse.Quote[index].high = i.High;
                                    }
                                    else if (j == QuoteField.Low)
                                    {
                                        serveResponse.Quote[index].low = i.Low;
                                    }
                                }
                                index++;
                            }
                            // send data
                            responseSerializer.Serialize(ClientStream, serveResponse);

                            // send EOF character so we can find the size of the data on the other side
                            ClientStream.Write(new byte[] { 26 }, 0, 1);

                            if (interval != 0)
                            {
                                await Task.Delay(1000 * interval);
                                goto SendData;
                            }
                        }
                    });
#pragma warning restore CS4014
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e.StackTrace);
            }
        }
Ejemplo n.º 35
0
 protected void LinkButtonSend_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         var quoteRequest = new QuoteRequest
         {
             Interests = String.Join(", ", CheckBoxListInterests.Items.Cast<ListItem>().Where(item => item.Selected).Select(item => item.Value).ToArray()),
             Name = TextBoxName.Text,
             Email = TextBoxEmail.Text,
             Phone = TextBoxPhone.Text,
             Company = TextBoxCompany.Text,
             Title = TextBoxTitle.Text,
             StreetAddress = TextBoxStreetAddress.Text,
             City = TextBoxCity.Text,
             Zip = TextBoxZip.Text,
             State = DropDownListState.SelectedValue,
             Country = DropDownListCountry.SelectedValue,
             EventDate = Text2DateTime(TextBoxEventDate.Text),
             EventLocation = TextBoxEventLocation.Text,
             NumberOfDays = Text2Int32(TextBoxNumberOfDays.Text),
             SetupRehearsalDate = Text2DateTime(TextBoxSetupRehearsalDate.Text),
             SetupRehearsalTime = TextBoxSetupRehearsalTime.Text,
             NumberOfVotingSystems = Text2Int32(TextBoxNumberOfVotingSystems.Text),
             NumberOfVotingDevicesPerSystem = TextBoxNumberOfVotingDevicesPerSystem.Text,
             AdditionalInformation = TextBoxAdditionalInformation.Text
         };
         quoteRequest.Save();
         var emailService = new EmailService(EmailService.form.quote);
         var notificationMessage = emailService.mailMessage;
         notificationMessage.Subject = "New quote request";
         notificationMessage.Body = String.Format(
     @"Interests: {0}
     Name: {1}
     Email: {2}
     Phone: {3}
     Company: {4}
     Title: {5}
     Street Address: {6}
     City: {7}
     Zip: {18}
     State: {8}
     Country: {9}
     Setup / Rehearsal Date: {13}
     Setup / Rehearsal Time: {14}
     Meeting/Event Dates: {10}
     Number of Days: {12}
     Event Location: {11}
     Number of Voting Systems: {15}
     Number of Voting Devices per System: {16}
     Additional Information:
     {17}
     ",
             String.Join(", ", CheckBoxListInterests.Items.Cast<ListItem>().Where(item => item.Selected).Select(item => item.Value).ToArray()),
             TextBoxName.Text,
             TextBoxEmail.Text,
             TextBoxPhone.Text,
             TextBoxCompany.Text,
             TextBoxTitle.Text,
             TextBoxStreetAddress.Text,
             TextBoxCity.Text,
             DropDownListState.SelectedValue,
             DropDownListCountry.SelectedValue,
             TextBoxEventDate.Text,
             TextBoxEventLocation.Text,
             Text2Int32(TextBoxNumberOfDays.Text),
             TextBoxSetupRehearsalDate.Text,
             TextBoxSetupRehearsalTime.Text,
             Text2Int32(TextBoxNumberOfVotingSystems.Text),
             TextBoxNumberOfVotingDevicesPerSystem.Text,
             TextBoxAdditionalInformation.Text,
             TextBoxZip.Text);
         emailService.sendMessage(notificationMessage);
         MultiViewQuoteRequest.SetActiveView(ViewResponse);
     }
 }
        public static void Main(string[] args)
        {
            var port    = 3000;
            var address = "127.0.0.1";

            var requestSerializer  = new XmlSerializer(typeof(QuoteRequest));
            var responseSerializer = new XmlSerializer(typeof(QuoteResponse));

            // Example QuoteRequest containing symbols and fields client wishes to fetch data about
            var request = new QuoteRequest
            {
                Fields = new List <QuoteField> {
                    QuoteField.High, QuoteField.Low, QuoteField.Close
                },
                Symbols = new List <string> {
                    "AAPL", "TSLA", "TWTR"
                },
                Interval = 3
            };

            try
            {
                // Initialize connection to server
                var    client     = new TcpClient(address, port);
                byte[] fromServer = new byte[8192];

                Console.WriteLine("Client Bound to Socket");
                using (var stream = client.GetStream())
                {
                    // Serialize request to server
                    requestSerializer.Serialize(stream, request);
                    // Temporary hacky fix for data preventing read blocking
                    client.Client.Shutdown(SocketShutdown.Send);

loop:
                    // write network stream to file stream
                    FileStream Disk = new FileStream(@"C:\Users\ftd-01\assignments\dotnet-io-concurrency-assignment-tjowers95\Client\data.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                    Disk.SetLength(0);
                    Disk.Seek(0, SeekOrigin.Begin);

                    // prevent null/uninitialized bytes from being read
                    do
                    {
                        Thread.Sleep(20);
                    } while (!stream.DataAvailable);

                    // read a fixed size so there's no infinite hang
                    stream.Read(fromServer, 0, 8192);

                    // find the size of the actual data by searching for the injected EOF character (unicode 26)
                    int i = 0;
                    while ((int)fromServer[i++] != 26)
                    {
                        ;
                    }

                    // allocate a new buffer without uninitialized / null bytes
                    byte[] toDisk = new byte[--i];
                    int    j      = 0;
                    while (j < i)
                    {
                        toDisk[j] = fromServer[j++];
                    }

                    Disk.Write(toDisk, 0, i);

                    Disk.Seek(0, SeekOrigin.Begin);
                    Disk.CopyTo(Console.OpenStandardOutput());
                    Disk.Close();

                    if (request.Interval > 0)
                    {
                        goto loop;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e.StackTrace);
            }
        }