public ProductDetailPageViewModel Load(params SearchParameter[] list)
        {
            ProductID = (int)list.FirstOrDefault(x => x.Name == "ProductID").Value;
            var product = _productService.Get(ProductID.ToString());
            var price   = _priceService.Search(new List <SearchParameter> {
                new SearchParameter {
                    Name  = "CountryID",
                    Value = Int32.Parse(_configuration["CountryID"])
                },
                new SearchParameter {
                    Name  = "ProductID",
                    Value = ProductID
                }
            });

            var productDetailPageModel = new ProductDetailPageModel
            {
                Content = (Model.Content.Content)_model
            };

            productDetailPageModel.AddProperty("product", product);
            productDetailPageModel.Price = price.FirstOrDefault().Value;

            return(new ProductDetailPageViewModel(productDetailPageModel));
        }
Exemple #2
0
        public DeliveryPageViewModel Load(params SearchParameter[] list)
        {
            var deliveryPageModel = new DeliveryPageModel
            {
                Content = (Model.Content.Content)_model
            };

            var options = _deliveryOptionSAL.Search(new List <SearchParameter> {
                new SearchParameter {
                    Name  = "CountryID",
                    Value = _configuration["CountryID"]
                }
            });

            var customerID = _httpContextAccessor.HttpContext.User.Identity.Name;

            var invoiceAddress = _invoiceAddressService.Get(customerID);

            deliveryPageModel.UserInvoiceAddress = true;
            deliveryPageModel.InvoiceAddress1    = invoiceAddress.Address1;
            deliveryPageModel.InvoiceAddress2    = invoiceAddress.Address2;
            deliveryPageModel.InvoiceAddress3    = invoiceAddress.Address3;
            deliveryPageModel.InvoiceAddress4    = invoiceAddress.Address4;
            deliveryPageModel.Postcode           = invoiceAddress.Postcode;
            deliveryPageModel.DeliveryOptions    = options;

            return(new DeliveryPageViewModel(deliveryPageModel));
        }
Exemple #3
0
        public DataResponse UpdateQuantity(int id, int value)
        {
            var item   = _basketService.Get(id.ToString());
            var result = _basketService.Put(new Model.APIModel.Purchase.Basket
            {
                BasketID   = id,
                Quantity   = value,
                ProductID  = item.ProductID,
                BasketGUID = item.BasketGUID
            }, id.ToString());


            return(new DataResponse {
                Type = result.Type
            });
        }
Exemple #4
0
        public CheckoutPageViewModel Load(params SearchParameter[] list)
        {
            var checkoutPageModel = new CheckoutPageModel
            {
                Content = (Model.Content.Content)_model
            };

            checkoutPageModel.Basket = _basketListItemSAL.Search(
                new List <SearchParameter> {
                new SearchParameter {
                    Name  = "CustomerID",
                    Value = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name)
                }
            });

            checkoutPageModel.InvoiceAddress         = _invoiceAddressSAL.Get(_httpContextAccessor.HttpContext.User.Identity.Name);
            checkoutPageModel.DeliveryAddress        = _deliveryAddressSAL.Get(_httpContextAccessor.HttpContext.User.Identity.Name);
            checkoutPageModel.SelectedBasketDelivery = _basketDeliverySAL.Get(_httpContextAccessor.HttpContext.User.Identity.Name);
            checkoutPageModel.DeliveryOption         = _deliveryOptionSAL.Get(checkoutPageModel.SelectedBasketDelivery.DeliveryOptionID.ToString());

            return(new CheckoutPageViewModel(checkoutPageModel));
        }
Exemple #5
0
        public DataResponse Process(DeliveryPageModel model)
        {
            var deliveryOptionExists = _basketDeliverySAL.Search(new List <SearchParameter> {
                new SearchParameter {
                    Name  = "CustomerID",
                    Value = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name)
                }
            });


            var deliveryOptionPrice = _deliveryOptionSAL.Get(model.DeliverySelection.ToString()).Price;

            if (!deliveryOptionExists.Any())
            {
                _basketDeliverySAL.Post(new BasketDelivery
                {
                    DeliveryOptionID = model.DeliverySelection,
                    CustomerID       = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name),
                    Value            = deliveryOptionPrice
                });
            }
            else
            {
                _basketDeliverySAL.Put(new BasketDelivery
                {
                    DeliveryOptionID = model.DeliverySelection,
                    CustomerID       = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name),
                    Value            = deliveryOptionPrice
                }, deliveryOptionExists.FirstOrDefault().CustomerID.ToString());
            }

            var addressExists = _deliveryAddressService.Get(_httpContextAccessor.HttpContext.User.Identity.Name);

            if (model.UserInvoiceAddress)
            {
                if (addressExists == null)
                {
                    _deliveryAddressService.Post(new Model.APIModel.Customer.DeliveryAddress
                    {
                        CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name),
                        Address1   = model.InvoiceAddress1,
                        Address2   = model.InvoiceAddress2,
                        Address3   = model.InvoiceAddress3,
                        Address4   = model.InvoiceAddress4,
                        Address5   = "",
                        Postcode   = model.Postcode
                    });
                }
                else
                {
                    _deliveryAddressService.Put(new Model.APIModel.Customer.DeliveryAddress
                    {
                        CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name),
                        Address1   = model.InvoiceAddress1,
                        Address2   = model.InvoiceAddress2,
                        Address3   = model.InvoiceAddress3,
                        Address4   = model.InvoiceAddress4,
                        Address5   = "",
                        Postcode   = model.Postcode
                    }, _httpContextAccessor.HttpContext.User.Identity.Name);
                }
            }

            if (model.NewAddress)
            {
                if (addressExists == null)
                {
                    _deliveryAddressService.Post(new Model.APIModel.Customer.DeliveryAddress
                    {
                        CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name),
                        Address1   = model.DeliveryAddress1,
                        Address2   = model.DeliveryAddress2,
                        Address3   = model.DeliveryAddress3,
                        Address4   = model.DeliveryAddress4,
                        Address5   = "",
                        Postcode   = model.DeliveryPostcode
                    });
                }
                else
                {
                    _deliveryAddressService.Put(new Model.APIModel.Customer.DeliveryAddress
                    {
                        CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name),
                        Address1   = model.DeliveryAddress1,
                        Address2   = model.DeliveryAddress2,
                        Address3   = model.DeliveryAddress3,
                        Address4   = model.DeliveryAddress4,
                        Address5   = "",
                        Postcode   = model.DeliveryPostcode
                    }, _httpContextAccessor.HttpContext.User.Identity.Name);
                }
            }

            return(new DataResponse {
                Type = Model.Enum.Response.DataResponseType.SUCCESS, Details = ""
            });
        }