Esempio n. 1
0
 public ActionResult Recharge(RechargeViewModel model)
 {
     RechargeRequest request = new RechargeRequest()
     {
         CreationTime = DateTime.Now,
         RequestID = Guid.NewGuid(),
         User = DbContext.Users.Single(u => u.UserName == User.Identity.Name),
     };
     switch(model.ValueUnit)
     {
         case RechargeValueUnit.GB:
             request.Amount = model.RechargeValue * 1024 * 1024 * 1024;
             break;
         case RechargeValueUnit.MB:
             request.Amount = model.RechargeValue * 1024 * 1024;
             break;
     }
     DbContext.RechargeRequests.Add(request);
     DbContext.SaveChanges();
     return RedirectToAction("Index", new { Message = ManageMessageId.RechargeSuccess });
 }
Esempio n. 2
0
 public ActionResult Recharge()
 {
     RechargeViewModel model = new RechargeViewModel() { RechargeValue = 1, ValueUnit = RechargeValueUnit.GB };
     return View(model);
 }