Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
            }
        }