示例#1
0
        public ActionResult AddToCart(Dictionary <string, string> item)
        {
            if (!item["culture"].IsNullOrEmpty())
            {
                Thread.CurrentThread.CurrentCulture = new CultureInfo(item["culture"]);
            }


            Product product_to_add = UvendiaContext.Products.Single <long>(long.Parse(item["p"]));
            string  size           = item["size"];

            if (product_to_add.HasVariant)
            {
                if (size.IsNullOrEmpty())
                {
                    product_to_add = product_to_add.Variants.First();
                }
                else
                {
                    product_to_add = product_to_add.Variants.First(x => string.Equals(x["Size"] as string, size, StringComparison.InvariantCultureIgnoreCase));
                }
            }

            var currentCart = CurrentCart.Create(SnuffoSettings.STORE_NAME);

            currentCart.AddProduct(product_to_add, int.Parse(item["qnty"]), SnuffoSettings.GetCurrency(), 0, item["thumb"]);

            return(PartialView("~/views/partials/_CartShop.cshtml", new CartShopModel()));
        }
示例#2
0
        public ActionResult ShopPage(ContentModel model, int page = 1, string sorting = "")
        {
            var settings      = SnuffoSettings.Create(model.Content);
            var shopPageModel = new ShopPageModel(model.Content);

            shopPageModel.Categories = UvendiaContext.Categories.GetByStoreId(settings.StoreId);
            shopPageModel.PageIndex  = page;

            long totalRows;
            long categoryId;

            long.TryParse(Request.QueryString["c"], out categoryId);
            long priceDefinitionId = UvendiaContext.PriceDefinitions.Single(SnuffoSettings.GetCurrency()).Id;
            var  sortBy            = sorting.IsNullOrEmpty() ? ProductSortyBy.Popularity : (ProductSortyBy)Enum.Parse(typeof(ProductSortyBy), sorting, true);

            var products = UvendiaContext.Products.GetProductsPaged(shopPageModel.PageIndex,
                                                                    shopPageModel.PageSize,
                                                                    out totalRows, categoryId > 0 ? categoryId : (long?)null,
                                                                    true,
                                                                    priceDefinitionId,
                                                                    sortyBy: sortBy);

            shopPageModel.TotalRows       = totalRows;
            shopPageModel.Products        = products;
            shopPageModel.SelectedSorting = sortBy.ToString();

            return(CurrentTemplate(shopPageModel));
        }
示例#3
0
        static CheckoutPageController()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Order, CheckoutOrder>()
                .ForMember(dest => dest.Company, opt => opt.MapFrom(src => SnuffoSettings.STORE_NAME))
                .ForMember(dest => dest.OrderReference, opt => opt.MapFrom(src => src.OrderNumber))
                .ForMember(dest => dest.IssuerId, opt => opt.MapFrom(src => src.MetaData))
                .ForMember(dest => dest.PaymentMethod, opt => opt.MapFrom(src => string.Equals(src.PaymentMethod.Name, CS.PaymentMethod.iDEAL.ToString(), StringComparison.InvariantCultureIgnoreCase) ? CS.PaymentMethod.iDEAL : CS.PaymentMethod.PayPal))
                .ForMember(dest => dest.OrderDate, opt => opt.MapFrom(src => src.OrderDate))
                .ForMember(dest => dest.CallBackUrlOnPaymentSucceed, opt => opt.Ignore())
                .ForMember(dest => dest.CallBackUrlOnPaymentFailed, opt => opt.Ignore())
                .ForMember(dest => dest.Currency, opt => opt.MapFrom(src => SnuffoSettings.GetCurrency()))
                .ForMember(dest => dest.ShippingFee, opt => opt.MapFrom(src => src.CalculateShippingFee()))
                .ForMember(dest => dest.ServiceFee, opt => opt.MapFrom(src => src.CalculatePaymentFee()))
                .ForMember(dest => dest.Subtotal, opt => opt.MapFrom(src => src.CalculateSubTotalWithoutVAT()))
                .ForMember(dest => dest.Total, opt => opt.MapFrom(src => src.CalculateTotal()))
                .ForMember(dest => dest.Discount, opt => opt.Ignore())
                .ForMember(dest => dest.VAT, opt => opt.MapFrom(src => src.CalculateVAT()));

                cfg.CreateMap <ProductOrderDetail, CheckoutOrderDetail>()
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Product.Sku))
                .ForMember(dest => dest.Quantity, opt => opt.MapFrom(src => src.Quantity))
                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Product.DisplayName(null)))
                .ForMember(dest => dest.UnitPrice, opt => opt.MapFrom(src => src.CalculatePriceWithDiscount()));

                cfg.CreateMap <TicketOrderDetail, CheckoutOrderDetail>()
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.TicketSale.Id))
                .ForMember(dest => dest.Quantity, opt => opt.MapFrom(src => src.Quantity))
                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.TicketSale.Description))
                .ForMember(dest => dest.UnitPrice, opt => opt.MapFrom(src => src.CalculatePriceWithDiscount()));
            });

            OrderMapper = config.CreateMapper();
            //Mapper.AssertConfigurationIsValid();
        }
示例#4
0
        public LanguageCurrencySelectModel(IPublishedContent content) : base(content)
        {
            var currency = SnuffoSettings.GetCurrency();

            SelectedCurrency = currency;
        }