public async Task <IActionResult> Create([Bind("MonsterId,Name,Health,Attack,Defense,Level")] Monster monster) { if (ModelState.IsValid) { _context.Add(monster); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(monster)); }
public async Task <IActionResult> Create([Bind("UserId,FirstName,LastName,EmailAddress,Password,Gold")] User user) { if (ModelState.IsValid) { string formvalue = Request.Form["UserType"]; int usertypeid = int.Parse(formvalue); user.UserType = _context.UserTypes.Find(usertypeid); user.DateAccountCreated = DateTime.Now; _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }