示例#1
0
        public ActionResult Create(Loan loan)
        {
            // Get and set the current user as the owner of the game/loan
            var currentUser = Membership.GetUser(User.Identity.Name, userIsOnline: true);
            if(currentUser != null)
            {
                loan.OwnerId = (Guid) currentUser.ProviderUserKey; // Every user _must_ have a GUID.
            }else
            {
                Trace.TraceError("Could not find user: "******"Index");
            }

            ViewBag.GameId = new SelectList(db.Games, "Id", "Name", loan.GameId);
            return View(loan);
        }
示例#2
0
 public ActionResult Edit(Loan loan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loan).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.OwnerId = new SelectList(db.Users, "UserId", "Username", loan.OwnerId);
     ViewBag.GameId = new SelectList(db.Games, "Id", "Name", loan.GameId);
     return View(loan);
 }