public IActionResult BuyNow(ElectronicDeviceViewModel boughtItem, PurchaseViewModel purchase) { purchase.TotalPrice += boughtItem.Price; ViewBag.Purchase = purchase; return(View("ConfirmPurchase")); }
public void IncrementNumberOfElementsAfterAddingItem() { CartViewModel cut = new CartViewModel(); ElectronicDeviceViewModel item = new ElectronicDeviceViewModel(); int numberOfElementsBeforeAdding = cut.NumberOfElements; cut.AddItemToCart(item); int numberOfElementsAfterAdding = cut.NumberOfElements; Assert.Equal(numberOfElementsAfterAdding, numberOfElementsBeforeAdding + 1); }
public void DeleteItemByIdFromCartIfPresent() { CartViewModel cut = new CartViewModel(); ElectronicDeviceViewModel item = new ElectronicDeviceViewModel(); item.ID = 1; item.Manufacturer = "Lenovo"; item.Photo = "photo.png"; item.Price = 2500; cut.AddItemToCart(item); bool wasDeleted = cut.DeleteFromCartById(1); Assert.True(wasDeleted); }
public void CalculateCorrectTotalPriceAfterAddingTwoElements() { CartViewModel cut = new CartViewModel(); ElectronicDeviceViewModel item = new ElectronicDeviceViewModel(); item.ID = 1; item.Manufacturer = "Lenovo"; item.Photo = "photo.png"; item.Price = 2500; ElectronicDeviceViewModel item2 = new ElectronicDeviceViewModel(); item2.ID = 2; item2.Manufacturer = "Acer"; item2.Photo = "photo2.png"; item2.Price = 5600; cut.AddItemToCart(item); cut.AddItemToCart(item2); Assert.Equal(5600 + 2500, cut.TotalPrice); }
/// <summary> /// Przekazanie wybranego produktu do kontrolera Cart /// </summary> /// <param name="itemToBuy"></param> /// <returns></returns> public IActionResult PassToCartController(ElectronicDeviceViewModel itemToBuy) { ViewBag.itemToBuy = itemToBuy; return(View("../Cart/BuyNow")); }
/// <summary> /// Dodanie do koszyka produktu /// </summary> /// <param name="item"></param> /// <returns></returns> public IActionResult AddToCart(ElectronicDeviceViewModel item) { cart.AddItemToCart(item); return(View("Index", cart)); }