public Product(string description, string yearPurchased, string monthPurchased, string dayPurchased, string warrantyInMonths, string priceWhenPurchased, Company manufacturer) { DatePurchased = DatePurchased.AddYears(int.Parse(yearPurchased) - 1); DatePurchased = DatePurchased.AddMonths(int.Parse(monthPurchased) - 1); DatePurchased = DatePurchased.AddDays(int.Parse(dayPurchased) - 1); SerialNumber = Guid.NewGuid(); Description = description; WarrantyInMonths = int.Parse(warrantyInMonths); PriceWhenPurchased = int.Parse(priceWhenPurchased); Manufacturer = manufacturer; }
public string this[string columnName] { get { if (columnName == "CouponLabel") { if (string.IsNullOrEmpty(CouponLabel)) { return("CouponLabel is required"); } } if (columnName == "PurchasedFrom") { if (string.IsNullOrEmpty(PurchasedFrom)) { return("Purchased from is required"); } } if (columnName == "DatePurchased") { if (null == DatePurchased || string.IsNullOrEmpty(DatePurchased.ToString())) { return("Purchased date is required"); } } if (columnName == "CashValue") { if (null == CashValue || CashValue <= 0) { return("Coupon value is required and should be greater than zero"); } } return(string.Empty); } }