public ProductListResponse GetAllProductsFor() { ProductListResponse productListResponse = new ProductListResponse(); try { IList <ProductViewModel> products = repository.GetAllProducts(); foreach (var product in products) { promotionService.Apply(product); } productListResponse.Products = products; productListResponse.Success = true; } catch (System.Data.SqlClient.SqlException ex) { // Log the exception... productListResponse.Success = false; // Return a friendly error message productListResponse.Message = "Check that your database is in the correct place."; } catch (Exception ex) { // Log the exception... productListResponse.Success = false; // Return a friendly error message productListResponse.Message = "An error occured"; } return(productListResponse); }
public decimal Checkout() { decimal totalPrice = 0m; foreach (var item in _items.Keys) { totalPrice += _promotionService.Apply(item, _items[item]); } return(totalPrice); }