public Add ( Product, product, Quantity, quantity ) : void | ||
product | Product, | |
quantity | Quantity, | |
Résultat | void |
public void ComputeTotalValue_ItemsWithQuantitySetAsOne_ReturnCalculated() { var cart = new Cart(); cart.Add(2, "itemName", (decimal)20.30); cart.Add(3, "itemName", (decimal)15.30); Assert.Equal((decimal) 35.60, cart.ComputeTotalValue()); }
public void ComputeTotalValue_ItemsWithQuantitySetWithVariousNumbers_ReturnCalculated() { var cart = new Cart(); cart.Add(2, "itemName", (decimal)20.30,2); cart.Add(3, "itemName", (decimal)15.30,3); Assert.Equal((decimal)86.50, cart.ComputeTotalValue()); }
public void Cart_Valid_Add_two_items_Should_Successed() { var sut = new Cart(); sut.Add(_item1); sut.Add(_item2); Assert.AreEqual(1.0m, sut.Total); Assert.AreEqual(2, sut.Items.Count); }
private void DataGridView1_CellDoubleClick(Object sender, DataGridViewCellEventArgs e) { if (dataGridView1.SelectedRows[0].DataBoundItem is Product product) { cart.Add(product); listBox2.Items.Add(product); UpdateLists(); } }
public void ScenanarioC() { //ARRANGE var A = new Product() { Name = "A", Price = 50 }; var B = new Product() { Name = "B", Price = 30 }; var C = new Product() { Name = "C", Price = 20 }; var D = new Product() { Name = "D", Price = 15 }; var productBundles = new ProductBundles(); //scenario b data set var cart = new Cart(); cart.Add(A); cart.Add(A); cart.Add(A); cart.Add(B); cart.Add(B); cart.Add(B); cart.Add(B); cart.Add(B); cart.Add(C); cart.Add(D); //Yes, we go definitly use Product instead of string, but let's KISS var flattenedCart = new List <string>(cart.CartProducts.Select(p => p.Name).ToList()); //Returning result from the recursing method - could perhaps have yieled var cartBundles = new List <string>(); var promotionCalculator = new PromotionCalculator(); //Find the applicabale bundles in the cart promotionCalculator.ApplicablePromotions(flattenedCart, productBundles.ActiveBundles, cartBundles); //Explicit Sum by remaing cart items var sum = cart.Sum(flattenedCart); //Plus prices for bundles sum += cart.Sum(cartBundles, productBundles.ActiveBundles); //ASSERT Assert.True(sum == 280); }
public void Can_Calculate_The_Total() { Cart cart = new Cart(); cart.Add(data[2], 3); cart.Add(data[7], 2); cart.Add(data[5], 3); Assert.AreEqual(159.8M, cart.CalculateTotal(), "Didn't get the right total price"); }
public void CashDeskTest() { //arrange var customer1 = new Customer() { Name = "TestUser1", CustomerID = 1 }; var customer2 = new Customer() { Name = "TestUser2", CustomerID = 2 }; var seller = new Seller() { Name = "TestSeller", SellerID = 1 }; var product1 = new Product() { Name = "TestPR1", Price = 5, Count = 5, ProductID = 1 }; var product2 = new Product() { Name = "TestPR2", Price = 10, Count = 10, ProductID = 2 }; var cart1 = new Cart(customer1); var cart2 = new Cart(customer2); cart1.Add(product1); cart1.Add(product1); cart1.Add(product2); cart2.Add(product2); cart2.Add(product2); var cashDesk = new CashDesk(1, seller); cashDesk.MaxQueueLenght = 10; cashDesk.Enqueue(cart1); cashDesk.Enqueue(cart2); var cart1Res = 20; var cart2Res = 20; //act var cart1ActualResult = cashDesk.Dequeue(); var cart2ActualResult = cashDesk.Dequeue(); //assert Assert.AreEqual(cart1Res, cart1ActualResult); Assert.AreEqual(cart2Res, cart2ActualResult); Assert.AreEqual(3, product1.Count); Assert.AreEqual(7, product2.Count); }
public void Can_Clear_Items() { Cart cart = new Cart(); cart.Add(data[7], 3); cart.Add(data[3], 2); cart.Add(data[8], 8); cart.clear(); Assert.AreEqual(0, cart.Items.Count); }
public void Basket_whenGiftVoucherAddedAndGiftCodeAppliedAndCodeIsValid_return_BasketTotal() { Cart cart = new Cart(); Product product1 = cart.Add(new Product("Hat", 10.50), 1); Product product3 = cart.Add(new Product("Jumper", 54.65), 1); GiftVoucher giftVoucher = new GiftVoucher("XXX-XXX", 5.00); Basket basket = new Basket(cart, giftVoucher); bool applied = basket.ApplyVoucher("XXX-XXX"); basket.Total.Should().Equals(60.15); }
public void IncludesPackageDeal() { var cart = new Cart(); cart.Add("LG4545", 1); cart.Add("HW089", 1); cart.Add("LT7733", 1); var order = checkoutService.Checkout(cart); Assert.AreEqual(24273.45M, order.SubTotal); }
public void Can_Add_Exist_Item() { Cart cart = new Cart(); cart.Add(data[1], 2); cart.Add(data[5], 5); cart.Add(data[6], 7); cart.Add(data[1], 6); Assert.AreEqual(3, cart.Items.Count); Assert.AreEqual(8, cart.Items[0].Quantity); }
public void Test_AllPricings_WithPromo() { var cart = new Cart(_inventory); cart.Add('X', 4); cart.Add('Y', 5); cart.Add('Z', 5); Assert.AreEqual( Math.Round(35.30f * 3) + 1000 + Math.Round(12.50f * 5) , cart.CheckOut() ); }
public void ShouldAddFreightCostWhenCartContainsMultipleCartItems() { var cart = new Cart(); cart.Add(new CartItem("Vara1", 50, 1)); cart.Add(new CartItem("Vara2", 75, 1)); cart.Add(new CartItem("Vara3", 25, 1)); cart.Add(new CartItem("Vara4", 100, 1)); Assert.AreEqual(300, cart.TotalPrice(), string.Format("Total price should be 300SEK but are {0}SEK.", cart.TotalPrice())); }
public void Test_AllPricings_WithPromo2() { var cart = new Cart(_inventory); cart.Add('X', 8); cart.Add('Y', 10); cart.Add('Z', 10); Assert.AreEqual( Math.Round(35.30f * 6) + 2000 + Math.Round(12.50f * 10) , cart.CheckOut() ); }
public void Basket_whenOfferVoucherAddedAndOffCodeAppledTiCategoryAppliedAndCartHasItemInCategory_return_Total() { Cart cart = new Cart(); Product product1 = cart.Add(new Product("Hat", 25.00), 1); Product product3 = cart.Add(new Product("Jumper", 26.00), 1); OfferVoucher expected = new OfferVoucher("YYY-YYY", 5.00, 50.00, new Category("Head Gear")); Basket basket = new Basket(cart, expected); bool IsCodeValid = basket.ApplyVoucher("YYY-YYY"); Assert.AreEqual(51.00, basket.Total); IsCodeValid.Should().BeFalse("There are no products in your basket applicable to voucher Voucher YYY-YYY"); }
public void CashDeskTest() { // arrange VeredContext dataBase = new VeredContext(); var client1 = dataBase.Clients.Where(i => i.ClientId == 1).FirstOrDefault(); var client2 = dataBase.Clients.Where(i => i.ClientId == 2).FirstOrDefault(); var seller = dataBase.Sellers.Where(i => i.SellerId == 3).FirstOrDefault(); var product1 = dataBase.Products.Where(i => i.ProductId == 4).FirstOrDefault(); var product2 = dataBase.Products.Where(i => i.ProductId == 5).FirstOrDefault(); var cart1 = new Cart(client1); cart1.Add(product1); cart1.Add(product1); cart1.Add(product2); var cart2 = new Cart(client2); cart2.Add(product1); cart2.Add(product2); cart2.Add(product2); var cashdesk1 = new CashDesk(seller, client1); var cashdesk2 = new CashDesk(seller, client2); decimal cart1ExpectedResult = 18.50M; decimal cart2ExpectedResult = 13.00M; // act decimal cart1ActualResult = cashdesk1.buyThroughPos(cart1); decimal cart2ActualResult = cashdesk2.buyThroughPos(cart2); // assert Assert.AreEqual(cart1ExpectedResult, cart1ActualResult); Assert.AreEqual(cart2ExpectedResult, cart2ActualResult); VeredContext dataBase2 = new VeredContext(); var product3 = dataBase2.Products.Where(i => i.ProductId == 4).FirstOrDefault(); var product4 = dataBase2.Products.Where(i => i.ProductId == 5).FirstOrDefault(); Assert.AreEqual(31, product3.CountOnShelf); Assert.AreEqual(74, product4.CountOnShelf); }
public void Can_Remove_Item() { Cart cart = new Cart(); cart.Add(data[2], 3); cart.Add(data[1], 2); cart.Add(data[3], 8); cart.Revome(data[2]); Assert.AreEqual(2, cart.Items.Count); Assert.IsNull(cart.Items.Find(x => x.Book.BookID == data[2].BookID)); }
public void Basket_whenOfferVoucherAddedAndOffCodeAppledTiCategoryAppliedAndCartHasItemInCategoryAndHasMinSpend_return_Total() { Cart cart = new Cart(); Product product1 = cart.Add(new Product("Hat", 25.00), 1); Product product2 = cart.Add(new Product("Jumper", 26.00), 1); Product product3 = cart.Add(new Product("Head Light", 3.50, new Category("Head Gear")), 1); OfferVoucher expected = new OfferVoucher("YYY-YYY", 5.00, 50.00, new Category("Head Gear")); Basket basket = new Basket(cart, expected); bool IsCodeValid = basket.ApplyVoucher("YYY-YYY"); Assert.AreEqual(51.00, basket.Total); IsCodeValid.Should().BeTrue(); }
static void Main(string[] args) { var cart = new Cart(); cart.ProductAddedEvent += DisplayAddedProduct; cart.ProductAddedEvent += AnotherEventHandler; cart.Add(new Product { Name = "Product-1", Price = 100.0m }); cart.Add(new Product { Name = "Product-2", Price = 200.0m }); }
public void CashDeskTest() { //Arrange Customer customer1 = new Customer() { Name = "test1", CustomerId = 1 }; Customer customer2 = new Customer() { Name = "test2", CustomerId = 2 }; Product product1 = new Product() { Name = "pr1", Count = 10, Price = 1, ProductId = 1 }; Product product2 = new Product() { Name = "pr2", Count = 10, Price = 2, ProductId = 2 }; Cart cart1 = new Cart(customer1); Cart cart2 = new Cart(customer2); Seller seller = new Seller() { Name = "seller1", SellerId = 1 }; CashDesk cashDesk = new CashDesk(seller, 1); cashDesk.maxLenght = 10; cashDesk.isModel = true; //Act cart1.Add(product1); cart1.Add(product1); cart1.Add(product2); cart2.Add(product2); cart2.Add(product2); cart2.Add(product1); cashDesk.Enqueue(cart1); cashDesk.Enqueue(cart2); decimal result1 = cashDesk.Dequeue(); decimal result2 = cashDesk.Dequeue(); //Assert Assert.AreEqual(4, result1); Assert.AreEqual(5, result2); Assert.AreEqual(7, product1.Count); Assert.AreEqual(7, product2.Count); }
public void TestCart() { Cart testCart = new Cart(commonUser); Item copyItem0 = items[0].Copy(1); Item copyItem1 = items[1].Copy(2); Item copyItem2 = items[2].Copy(3); testCart.Add(copyItem0); testCart.Add(copyItem2); Assert.AreEqual(testCart.TotalCost(), 50000); testCart.Add(copyItem1); Assert.AreEqual(testCart.TotalCost(), 50200); }
public void CartTest() { // Arrange - объявление var customer = new Customer() { Name = "TestUser" }; var product1 = new Product() { ProductId = 1, Name = "pr1", Price = 100, Count = 10 }; var product2 = new Product() { ProductId = 2, Name = "prod3", Price = 200, Count = 20 }; var cart = new Cart(customer); var expectedResult = new List <Product>() { product1, product1, product2 }; // Act - выполнение действие cart.Add(product1); cart.Add(product1); cart.Add(product2); var cartResult = cart.GetAll(); // Assert - сравнение ожидаемого результата и что получилось по факту Assert.AreEqual(expectedResult.Count, cartResult.Count); for (int i = 0; i < expectedResult.Count; i++) { Assert.AreEqual(expectedResult[i], cartResult[i]); } }
public void CartTest() { //arrange var customer = new Customer() { CustomerId = 1, Name = "test" }; var product = new Product() { ProductId = 1, Name = "pr1", Price = 100, Count = 1, Color = "White" }; var product1 = new Product() { ProductId = 2, Name = "pr2", Price = 10, Count = 10, Color = "Black" }; var cart = new Cart(customer); var expectedResult = new List <Product>() { product1, product }; //act cart.Add(product1); cart.Add(product); var cartResult = cart.GetAll(); //assert Assert.AreEqual(expectedResult.Count, cartResult.Count); for (int i = 0; i < expectedResult.Count; i++) { Assert.AreEqual(expectedResult[i], cartResult[i]); } }
public void CartTest() { //Патерн шаблон //arrange //ЭТО бьявления. Где мы создаем входные и итоговые данные var customer = new Customer() { CustomerId = 1, Name = "testuser", }; var product1 = new Product() { ProductId = 1, Name = "pr1", Price = 100, Count = 10 }; var product2 = new Product() { ProductId = 2, Name = "pr2", Price = 200, Count = 20 }; var cart = new Cart(customer); var expectedResult = new List <Product>() { product1, product1, product2 }; //act //Это выполнение действия cart.Add(product1); cart.Add(product1); // добавление cart.Add(product2); var cartResult = cart.GetAll(); // получение данных из метода для сравнения //assert //Сравнение результотов ожидаемого кода и полученного в момент работы // сравниваем количество. Assert.AreEqual(expectedResult.Count, cartResult.Count); for (int i = 0; i < expectedResult.Count; i++) { Assert.AreEqual(expectedResult[i], cartResult[i]); //сравнение } }
public void CartTest() { // Arrange var customer = new Customer() { CustomerId = 1, Name = "TestUser" }; var product1 = new Product() { ProductId = 1, Name = "pr1", Price = 100, Count = 10 }; var product2 = new Product() { ProductId = 2, Name = "pr2", Price = 200, Count = 20 }; var cart = new Cart(customer); var expectedResult = new List <Product>() { product1, product1, product2 }; // Act cart.Add(product1); cart.Add(product1); cart.Add(product2); var cartResult = cart.GetAllProducts(); // Assert Assert.AreEqual(expectedResult.Count, cartResult.Count); for (int i = 0; i < expectedResult.Count; i++) { Assert.AreEqual(expectedResult[i], cartResult[i]); } }
public void CartTest() { //Arrenge Customer customer = new Customer() { CustomerId = 1, Name = "TestUser", }; Product product1 = new Product() { ProductId = 1, Name = "productTest1", Price = 100, Count = 10, }; Product product2 = new Product() { ProductId = 2, Name = "productTest2", Price = 200, Count = 20, }; Cart cart = new Cart(customer); List <Product> products = new List <Product>() { product1, product1, product2, }; //Act cart.Add(product1); cart.Add(product1); cart.Add(product2); List <Product> carProducts = cart.GetAll(); //Assert Assert.AreEqual(products.Count, carProducts.Count); for (int i = 0; i < products.Count; i++) { Assert.AreEqual(products[i], carProducts[i]); } }
public void DoesNotApplyDiscountToEntireOrder() { var cart = new Cart(); cart.Add("LG4545", 1); cart.Add("HW089", 1); cart.Add("LT7733", 1); cart.Add("L312", 2); var order = checkoutService.Checkout(cart); Assert.AreEqual(52271.45M, order.SubTotal); Assert.AreEqual(601, order.ShippingCost); Assert.AreEqual(52872.45M, order.Total); }
public void CartTest() { //Arrange - объявление(входные данные и ожидаемые/выходные) var customer = new Customer() { CustomerId = 1, Name = "testUser" }; var product1 = new Product() { Name = "pr1", Price = 100, Count = 10, ProductId = 1 }; var product2 = new Product() { Name = "pr2", Price = 200, Count = 20, ProductId = 2 }; var cart = new Cart(customer); var expectedResult = new List <Product>() { product1, product1, product2 }; //Act - выполнение действия cart.Add(product1); cart.Add(product1); cart.Add(product2); var cartResult = cart.GetAll(); //Assert - выполнение сравнения ожидаемого результата от фактического Assert.AreEqual(expectedResult.Count, cart.GetAll().Count); for (int i = 0; i < expectedResult.Count; i++) { Assert.AreEqual(expectedResult[i], cartResult[i]); } }
public Cart ComputeCart(List <CartItem> cartItems) { var result = new Cart(); var customerDiscounts = _discountContext.CustomerDiscounts .Where(x => x.IsRemoved == false && x.StartDate <DateTime.Now && x.EndDate> DateTime.Now) .Select(x => new { ProductId = x.ProductId, DiscountRate = x.DiscountRate }) .AsNoTracking().ToList(); var colleagueDiscounts = _discountContext.ColleagueDiscounts .Where(x => x.IsRemoved == false) .Select(x => new { DiscountRate = x.DiscountRate, ProductId = x.ProductId }) .AsNoTracking().ToList(); var currentUserRole = _authHelper.GetCurrentUserRole(); if (currentUserRole == Roles.Colleague) { foreach (var cartItem in cartItems) { var discount = colleagueDiscounts.FirstOrDefault(x => x.ProductId == cartItem.Id); if (discount != null) { cartItem.DiscountRate = discount.DiscountRate; } cartItem.Discount = double.Parse(cartItem.Price.Replace("٬", "")) * cartItem.DiscountRate / 100; cartItem.Payment = double.Parse(cartItem.TotalPrice.Replace("٬", "")) - cartItem.Discount; result.Add(cartItem); } } else { foreach (var cartItem in cartItems) { var discount = customerDiscounts.FirstOrDefault(x => x.ProductId == cartItem.Id); if (discount != null) { cartItem.DiscountRate = discount.DiscountRate; } cartItem.Discount = double.Parse(cartItem.Price.Replace("٬", "")) * cartItem.DiscountRate / 100; cartItem.Payment = double.Parse(cartItem.TotalPrice.Replace("٬", "")) - cartItem.Discount; result.Add(cartItem); } } return(result); }
public void StartUp() { Console.WriteLine("Please choose an action and a product:" + " Apple/Book/Toy/Show Cart/END"); string[] commands = Console.ReadLine().Split(' ').ToArray(); do { if (commands[0] == "Add") { if (commands[1] == "Apple") { cart.Add(apple); } if (commands[1] == "Book") { cart.Add(book); } if (commands[1] == "Toy") { cart.Add(toy); } } if (commands[0] == "Remove") { if (commands[1] == "Apple") { cart.Remove(apple); } if (commands[1] == "Book") { cart.Remove(book); } if (commands[1] == "Toy") { cart.Remove(toy); } } if (commands[0] == "Show Cart") { cart.Print(); } commands = Console.ReadLine().Split(' ').ToArray(); }while (commands[0] == "END"); Console.WriteLine("-------------------------------- "); Console.WriteLine("Thank you for choosing us!"); Console.WriteLine("-------------------------------- "); }
public void AddToCart() { CartItemDisplayModel existingItem = Cart.FirstOrDefault(x => x.Product == SelectedProduct); if (existingItem != null) { existingItem.QuantityInCart += ItemQuantity; // Hack - there should be a better way of refreshing the cart display Cart.Remove(existingItem); Cart.Add(existingItem); } else { CartItemDisplayModel item = new CartItemDisplayModel { Product = SelectedProduct, QuantityInCart = ItemQuantity }; Cart.Add(item); } SelectedProduct.QuantityInStock -= ItemQuantity; ItemQuantity = 1; NotifyOfPropertyChange(() => SubTotal); NotifyOfPropertyChange(() => Tax); NotifyOfPropertyChange(() => Total); NotifyOfPropertyChange(() => CanCheckout); }
public void Clear_ClearExistedItems_SucceedClear() { Car car1 = new Car { CarId = 1, Price = 5 }; Car car2 = new Car { CarId = 2, Price = 8.9M }; Cart cart = new Cart(); cart.Add(car1, 1); cart.Add(car2, 2); cart.Add(car2, 3); cart.Clear(); Assert.Empty(cart.GetPickedItems); }
public void MyCartIs(Table cart) { Cart = new Cart(); foreach (var row in cart.Rows) { Cart.Add(row[0]); } }
public double Price(params int[] books) { var cart = new Cart(); foreach (var book in books) cart.Add(book); return cart.Total; }
public void AddCableToCart() { //Arrange Cart cart = new Cart(); OrderItem item = new OrderItem("cable", 1); //Act cart.Add(item); //Assert OrderItem match = cart.Items.Find(x => x.Name == "cable"); Assert.AreEqual(match.Name, "cable"); Assert.AreEqual(match.Quantity, 1); }
public void Generate(ChartResultParameter par) { DateTime begin = DateTime.Now; HtmlTemplate index = new HtmlTemplate("index"); string articlesString = "", cancellationsString = "", depositsString = ""; string usersString = ""; double sum = 0.0; result.Sales.Sort(par.SortOrder); result.Cancellations.Sort(par.SortOrder); index.Insert("datetime", DateTime.Now.ToString()); index.Insert("version", Administration.Properties.Resources.Version); #region information index.Insert("profile", chart.Profile.Name); foreach (User u in chart.Users) usersString += u.Username + "<br />\r\n"; usersString.Remove(usersString.Length - 8); index.Insert("user", usersString); index.Insert("cancellationsInvolved", par.InvolveCancellation ? "ja" : "nein"); index.Insert("deletedArticlesShown", par.ShowDeletedArticles ? "ja" : "nein"); index.Insert("sortedBy", par.SortOrder.ToString()); #endregion #region articles HtmlTemplate articles = new HtmlTemplate("articlecollection"); articles.Insert("header", "Artikel"); foreach (ArticleCount ac in result.Sales.Container) { if (!par.ShowDeletedArticles && ac.Article.IsDeleted) continue; if (!par.ShowUnsoldArticles && ac.Count < 1) continue; HtmlTemplate tpl = new HtmlTemplate("article"); tpl.Insert("name", ac.Article.Name); tpl.Insert("price", string.Format("{0:0.00 €}", ac.Article.Price)); tpl.Insert("count", par.InvolveCancellation ? (ac.Count - result.Cancellations[ac.Article].Count).ToString() : ac.Count.ToString()); tpl.Insert("sum", par.InvolveCancellation ? string.Format("{0:0.00 €}", ac.Article.Price * (ac.Count - result.Cancellations[ac.Article].Count)) : string.Format("{0:0.00 €}", ac.Article.Price * ac.Count)); articlesString += tpl.Get(); } articles.Insert("articles", articlesString); articles.Insert("articlescount", par.InvolveCancellation ? (result.Sales.Count - result.Cancellations.Count).ToString() : result.Sales.Count.ToString()); sum = par.InvolveCancellation ? (result.Sales.Amount - result.Cancellations.Amount) : result.Sales.Amount; articles.Insert("articlessum", string.Format("{0:0.00 €}", sum)); index.Insert("sales", articles.Get()); #endregion #region deposits double depositSum = 0.0; int depositCount = 0; List<ArticleCount> deps = (from d in result.Sales.Container where d.Article.Deposit.DepositID != -1 select d as ArticleCount).ToList(); List<ArticleCount> depcancs = (from d in result.Cancellations.Container where d.Article.Deposit.DepositID != -1 select d as ArticleCount).ToList(); Cart depresult = new Cart(); foreach (ArticleCount d in deps) depresult.Add(d); if (par.InvolveCancellation) // remove cancelled deposites foreach (ArticleCount d in depcancs) depresult.Remove(d); // add returned deposites which are not children of depresult (never bought it, but returned it) List<DepositReturn> unbought = (from d in result.DepositReturns where (from a in depresult.Container select a.Article.Deposit).ToList<Deposit>().Contains(d.Deposit) == false select d).ToList(); foreach (DepositReturn d in unbought) { int count = d.Count; HtmlTemplate tpl = new HtmlTemplate("article"); tpl.Insert("name", d.Deposit.Name); tpl.Insert("price", string.Format("{0:0.00 €}", d.Deposit.Amount)); tpl.Insert("count", count.ToString()); tpl.Insert("sum", string.Format("{0:0.00 €}", count * d.Deposit.Amount)); depositSum -= count * d.Deposit.Amount; depositCount -= count; depositsString += tpl.Get(); } // enumerate deposit objects foreach (ArticleCount d in depresult.Container) { int count = d.Count; // subtract returned deposites foreach (DepositReturn dr in (from ret in result.DepositReturns where ret.Deposit.DepositID == d.Article.Deposit.DepositID select ret).ToList()) { count -= dr.Count; } HtmlTemplate tpl = new HtmlTemplate("article"); tpl.Insert("name", d.Article.Deposit.Name); tpl.Insert("price", string.Format("{0:0.00 €}", d.Article.Deposit.Amount)); tpl.Insert("count", count.ToString()); tpl.Insert("sum", string.Format("{0:0.00 €}", count * d.Article.Deposit.Amount)); depositSum += count * d.Article.Deposit.Amount; depositCount += count; depositsString += tpl.Get(); } if (par.ShowDeposits) { HtmlTemplate deposits = new HtmlTemplate("articlecollection"); deposits.Insert("header", "Pfänder"); deposits.Insert("articles", depositsString); deposits.Insert("articlescount", depositCount.ToString()); deposits.Insert("articlessum", string.Format("{0:0.00 €}", depositSum)); index.Insert("deposits", deposits.Get()); } else index.Insert("deposits", ""); #endregion #region cancellations if (par.ShowCancellation) { HtmlTemplate cancellations = new HtmlTemplate("articlecollection"); cancellations.Insert("header", "Stornos"); foreach (ArticleCount ac in result.Cancellations.Container) { HtmlTemplate tpl = new HtmlTemplate("article"); tpl.Insert("name", ac.Article.Name); tpl.Insert("price", string.Format("{0:0.00 €}", ac.Article.Price)); tpl.Insert("count", ac.Count.ToString()); tpl.Insert("sum", string.Format("{0:0.00 €}", ac.Article.Price * ac.Count)); cancellationsString += tpl.Get(); } cancellations.Insert("articles", cancellationsString); cancellations.Insert("articlescount", result.Cancellations.Count.ToString()); cancellations.Insert("articlessum", string.Format("{0:0.00 €}", result.Cancellations.Amount)); index.Insert("cancellations", cancellations.Get()); } else index.Insert("cancellations", ""); #endregion #region staff if (par.ShowCalculation) { HtmlTemplate calculation = new HtmlTemplate("staffcalculation"); calculation.Insert("header", "Abrechnung"); calculation.Insert("sum", string.Format("{0:0.00 €}", sum)); calculation.Insert("commissionpercentage", string.Format("{0:0.0 %}", par.Provision / 100)); calculation.Insert("commissionamount", string.Format("{0:0.00 €}", sum * par.Provision / 100)); calculation.Insert("benefit", string.Format("{0:0.00 €}", par.FreeAmount)); calculation.Insert("depositsum", string.Format("{0:0.00 €}", depositSum)); calculation.Insert("summary", string.Format("{0:0.00 €}", sum + depositSum - (sum * par.Provision / 100) - par.FreeAmount)); index.Insert("staff", calculation.Get()); } else index.Insert("staff", ""); #endregion index.Insert("creationduration", (result.CreationBegin - result.CreationEnd).ToString()); index.Insert("writingduration", (begin - DateTime.Now).ToString()); this.output = index.Get(); }
private void AddAlbumsToCart(IList<Guid> albumsToAdd, Cart cart) { if (!albumsToAdd.Any()) { return; } foreach (var album in albumsToAdd.Select(productId => _albumRepository.FindBy(productId))) { cart.Add(album); } }