public async Task <HomeViewModel> GetHomeViewModel() { var siteProfile = await _settings.GetSiteProfile(); var catalog = new List <CatalogModel>(); var categories = await _categoryService.GetAllPublishedWithProductsAndStyles(); foreach (var category in categories) { var catalogModel = new CatalogModel(category.Name, category.Position); var categoryProducts = category.ProductCategories.Select(x => x.Product).OrderBy(x => x.ProductName); foreach (var product in categoryProducts) { catalogModel.Products.Add(new ProductsAzViewModel { Id = product.Id, Name = product.ProductName, Slug = product.Slug, Price = $"{product.Styles?.FirstOrDefault()?.Price:n2}", ImgSource = "images/" + product.Slug + ".jpg" }); } catalog.Add(catalogModel); } return(new HomeViewModel { Catalog = catalog, SiteTitle = siteProfile?.SiteTitle ?? "NEW SITE", Description = siteProfile?.Description ?? "NEW SITE DESCRIPTION" }); }
public async Task GetApiContext_GivenAPaymentRequestWithValidApiCredentials_ReturnsAnApiContextWithAValidRequestId() { //arrange var settings = await _settings.Get(); var profile = await _settings.GetSiteProfile(); var sut = _fixture.Resolve <IPaypalService>(); var options = new PaymentRequestOptions(profile, settings, _fixture.ProductionCheckoutUri); var paymentRequest = new PaymentRequest(CartViewStubs.Get(), options); //act var apiContext = sut.GetApiContext(paymentRequest); //assert Assert.Equal(36, apiContext.RequestId.Length); }
public async Task <string> Start(string sessionId, Uri requestUri, bool isSandbox) { var settings = await _siteSettingsService.Get(); var profile = await _siteSettingsService.GetSiteProfile(); var cart = await _cartService.GetCartViewModel(sessionId); var paymentRequestOptions = new PaymentRequestOptions(profile, settings, requestUri, isSandbox); var paymentRequest = new PaymentRequest(cart.Items, paymentRequestOptions); var redirectUrl = _paypalService.PayWithPaypal(paymentRequest); return(redirectUrl); }
public async Task <decimal> Calculate(decimal subtotal) { if (subtotal == 0.00m) { return(0.00m); } var profile = await _siteSettingsService.GetSiteProfile(); var freeShippingThreshold = profile?.FreeShippingThreshold ?? 0.0m; var flatShippingRate = profile?.FlatShippingRate ?? 0.0m; return(subtotal >= freeShippingThreshold ? 0.00m : flatShippingRate); }
public async Task <SiteSettingsViewModel> Get() => new SiteSettingsViewModel { SiteSettings = await _siteSettingsService.Get(), SiteProfile = await _siteSettingsService.GetSiteProfile() };