Advertisement
185522x

Untitled

Jul 18th, 2019
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6.  
  7.  
  8.  
  9. //IEquatable - type-specific to determine the equality of Instances
  10. public class ShoppingCartItem : IEquatable <ShoppingCartItem>
  11. {
  12. public int Quantity { get; set; }
  13.  
  14. private string _ItemID;
  15. public string ItemID
  16. {
  17. get { return _ItemID; }
  18. set { _ItemID = value; }
  19. }
  20.  
  21. private string _ItemName;
  22. public string Product_Name
  23. {
  24. get { return _ItemName; }
  25. set { _ItemName = value; }
  26. }
  27.  
  28. private string _ItemImage;
  29. public string Product_Image
  30. {
  31. get { return _ItemImage; }
  32. set { _ItemImage = value; }
  33. }
  34. private string _ItemDesc;
  35. public string Product_Desc
  36. {
  37. get { return _ItemDesc; }
  38. set { _ItemDesc = value; }
  39.  
  40. }
  41.  
  42. private decimal _ItemPrice;
  43. public decimal Product_Price
  44. {
  45. get { return _ItemPrice; }
  46. set { _ItemPrice = value; }
  47. }
  48.  
  49. public decimal TotalPrice
  50. {
  51. get { return Product_Price * Quantity; }
  52. }
  53.  
  54. public ShoppingCartItem(string productID)
  55. {
  56. this.ItemID = productID;
  57. }
  58.  
  59. public ShoppingCartItem(string productID, Product prod)
  60. {
  61. this.ItemID = productID;
  62. this.Product_Name = prod.Product_Name;
  63. this.Product_Desc = prod.Product_Desc;
  64. this.Product_Price = prod.Unit_Price; ;
  65. this.Product_Image = prod.Product_Image;
  66. }
  67.  
  68. public ShoppingCartItem(string productID, string productName, string productDesc, decimal productPrice, string productImage)
  69. {
  70. this.ItemID = productID;
  71. this.Product_Name = productName;
  72. this.Product_Desc = productDesc;
  73. this.Product_Price = productPrice;
  74. this.Product_Image = productImage;
  75. }
  76.  
  77. public bool Equals(ShoppingCartItem anItem)
  78. {
  79. return anItem.ItemID == this.ItemID;
  80. }
  81.  
  82. //public bool Equals(ShoppingCartItem product)
  83. //{
  84. // return product.ItemID == this.ItemID;
  85. //}
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement