Esempio n. 1
0
        // Write the default parameterless contructor and another version that sets
        // the year, address, price, income and expanse

        public override string ToString()
        {
            return("Street Address: " + Address + "\n"
                   + "Year built: " + Year + "\n"
                   + "Purchase price: " + PurchasePrice.ToString("C") + "\n"
                   + "Income rent: " + IncomeFromRent.ToString("C") + "\n"
                   + "Montly expense: " + MontlyExpense.ToString("C") + "\n"
                   + "Montly earning: " + MontlyEarnings.ToString("C"));
        }
Esempio n. 2
0
        public override string ToString()
        {
            //this method must return a string
            string outputStr = "Street Address: " + Address + "\n"
                               + "Year Built: " + Year + "\n"
                               + "Purchase Price: " + PurchasePrice.ToString("C") + "\n"
                               + "Income From Rent: " + IncomeFromRent.ToString("C") + "\n"
                               + "Monthly Expense: " + MonthlyExpense.ToString("C") + "\n"
                               + "Monthly Earnings: " + MonthlyEarnings.ToString("C");

            return(outputStr);
        }
Esempio n. 3
0
        /// <summary>
        /// Ajoute les données de l'entités dans un dictionnaire pour assurer la correspondance entre attributs et colonnes
        /// </summary>
        /// <returns> Le dictionnaire </returns>
        public Dictionary <string, string> Fetch()
        {
            Dictionary <string, string> res = new Dictionary <string, string>
            {
                { "nom", Name },
                { "designation", Designation },
                { "prix_achat", PurchasePrice.ToString(CultureInfo.CurrentCulture) },
                { "prix_vente", SellPrice.ToString(CultureInfo.CurrentCulture) },
                { "tva", TVA.ToString(CultureInfo.CurrentCulture) },
                { "code_ean", EANCode }
            };

            return(res);
        }
        public VehicleValidator()
        {
            RuleFor(x => x.VIN).Cascade(CascadeMode.StopOnFirstFailure)
            .MaximumLength(100)
            .WithMessage("Maximum length is 100 characters.");
            RuleFor(x => x.Make).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage("Make is required.")
            .MaximumLength(15).WithMessage("Maximum length is 15 characters.");
            RuleFor(x => x.Model).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage("Model is required.")
            .MaximumLength(15).WithMessage("Maximum length is 15 characters.");
            RuleFor(x => x.Trim).Cascade(CascadeMode.StopOnFirstFailure)
            .MaximumLength(10).WithMessage("Maximum length is 10 characters.");
            RuleFor(x => x.Color).Cascade(CascadeMode.StopOnFirstFailure)
            .MaximumLength(15).WithMessage("Maximum length is 15 characters.");


            RuleFor(x => x.Mileage).Cascade(CascadeMode.StopOnFirstFailure)
            .Must(Mileage => Double.TryParse(Mileage, out double result))
            .When(vm => vm.Mileage != null)
            .WithMessage("Mileage must contain only numbers and commas.")
            .Must(Mileage => double.Parse(Mileage) >= 0)
            .When(vm => vm.Mileage != null)
            .WithMessage("Mileage must 0 or greater.");

            //RuleFor(x => x.Year).Cascade(CascadeMode.StopOnFirstFailure)
            //    .NotEmpty().WithMessage("Year is required.")
            //    .Must(Year => int.TryParse(Year, out int result))
            //        .WithMessage("Year must contain only numbers. ")
            //    .GreaterThan("1990").WithMessage("Must be greater than 1990.")
            //    .LessThanOrEqualTo(DateTime.Now.Year.ToString()).WithMessage("Must be current year or earlier.");


            RuleFor(x => x.PurchasePrice).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage("Purchase Price is required.")
            .Must(PurchasePrice => PriceMustBeACurrency(PurchasePrice.ToString()))
            .WithMessage("Purchase price may include only numbers, commas, and decimals.")
            .Must(PurchasePrice => PriceMustBeGreaterThanZero(PurchasePrice.ToString()))
            .WithMessage("Purchase price must be greater than 0.");



            RuleFor(x => x.PurchaseDate).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage("Purchase date is required.")
            .LessThanOrEqualTo(DateTime.Today).WithMessage("Date must be today or earlier.");
            RuleFor(x => x.LotDate).Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage("Lot date is required.")
            .GreaterThanOrEqualTo(x => x.PurchaseDate).WithMessage("Date cannot be before purchase date.");
        }
        /// <summary>
        /// Convert the purchased prod into a string of params for paypal description
        /// </summary>
        /// <returns></returns>
        public string CreatePayPalItemDescriptions(int index)
        {
            string ReturnString = string.Empty;

            string Description = string.Empty;

            ReturnString += String.Format("&L_PAYMENTREQUEST_0_NAME{0}={1}", index, Uri.EscapeDataString(Name));

            if (SelectedCheckoutProperties != null && SelectedCheckoutProperties.Count > 0)
            {
                for (int myIndex = 0; myIndex < SelectedCheckoutProperties.Count; myIndex++)
                {
                    CheckoutPropertySettingKey SelectedProp = SelectedCheckoutProperties[myIndex];

                    Description += SelectedProp.Key + ": " + SelectedProp.Value;

                    if (myIndex != SelectedCheckoutProperties.Count - 1)
                    {
                        Description += ", ";
                    }
                }
            }

            ReturnString += String.Format("&L_PAYMENTREQUEST_0_DESC{0}={1}", index, Description);
            ReturnString += String.Format("&L_PAYMENTREQUEST_0_AMT{0}={1}", index, Uri.EscapeDataString(PurchasePrice.ToString("0.00")));
            ReturnString += String.Format("&L_PAYMENTREQUEST_0_QTY{0}={1}", index, Uri.EscapeDataString(Quantity.ToString()));

            return(ReturnString);
        }