コード例 #1
0
        public IActionResult BuyMiles()
        {
            // Generates a new instance of BuyMilesViewModel
            var models = new List <BuyMilesViewModel>();

            // Creates a new integer to use in the while
            var i = 1;

            // Assigns values to the new BuyMilesViewModel
            while (i < 11)
            {
                var mile = new BuyMilesViewModel
                {
                    Amount   = 2000 * i,
                    Price    = 70 * i,
                    Selected = false
                };

                i++;

                models.Add(mile);
            }

            return(View(models));
        }
コード例 #2
0
 public Mile ToMile(BuyMilesViewModel model, int clientId, int extraYears)
 {
     return(new Mile
     {
         ClientId = clientId,
         Qtd = model.Amount,
         MilesTypeId = 2,
         ExpirationDate = DateTime.Now.AddYears(extraYears)
     });
 }
コード例 #3
0
 public Transaction ToTransaction(BuyMilesViewModel model, Mile mile)
 {
     return(new Transaction
     {
         Description = "Buy",
         Value = mile.Qtd,
         TransactionDate = DateTime.Now,
         Price = model.Price,
         ClientID = mile.ClientId,
         IsAproved = true,
         IsCreditCard = false
     });
 }