public ActionResult Index()
        {
            CheckoutShippingViewModel model = new CheckoutShippingViewModel();

            Cart cart = GetOrSetCart();

            if (cart.Items == null || cart.Items.Length == 0)
            {
                return(RedirectToAction("Index", "Cart"));
            }

            model.quote = QuoteService.CreateQuote(cart);

            model.quote.Address = new Address();

            model.Countries = CountryCodeService.GetCountries().Select(x => new SelectListItem()
            {
                Value    = x.Code,
                Text     = x.Name,
                Selected = x.Code == model.quote.Address.Country
            });

            HttpCookie newQuoteCookie = new HttpCookie("QuoteKey");

            newQuoteCookie.Value   = model.quote.QuoteKey.ToString();
            newQuoteCookie.Expires = DateTime.Now.AddDays(1);
            ControllerContext.HttpContext.Response.Cookies.Set(newQuoteCookie);

            return(View(model));
        }
Exemple #2
0
        public void countrycodeservice_can_get_country_codes_test()
        {
            //given
            ICountryCodeService service = new CountryCodeService(new JsonSerializationService <ISOCountryCodeCollection>());
            //when
            var countryCodes = service.GetCountryCodes();

            //then
            countryCodes.Should().NotBeNull();
        }
Exemple #3
0
        public void countrycodeservice_can_get_country_code_by_iso_long_code_test()
        {
            //given
            ICountryCodeService service = new CountryCodeService(new JsonSerializationService <ISOCountryCodeCollection>());
            string isoLongCode          = "PNG";
            //when
            var countryCode = service.GetCountryCodeByISOLongCode(isoLongCode);

            //then
            countryCode.Value.Should().Be("PNG");
        }