public async Task <IActionResult> Edit(decimal id, [Bind("Orderid,OrderDate,Userid,OrderCount,OrderPrice,Gameid,Cardid,Eventgameid,DiscountRate")] Order order) { if (id != order.Orderid) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(order); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(order.Orderid)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Gameid"] = new SelectList(_context.Game, "Gameid", "Description", order.Gameid); ViewData["Userid"] = new SelectList(_context.User, "Userid", "Password", order.Userid); return(View(order)); }
public async Task <IActionResult> Create([Bind("Platformid,Platformname,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Platform platform) { if (ModelState.IsValid) { platform.CreatedDatetime = DateTime.Now; platform.UpdatedDatetime = DateTime.Now; _context.Add(platform); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(platform)); }
public async Task <IActionResult> Create([Bind("Categoryid,Categoriname,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Category category) { if (ModelState.IsValid) { category.CreatedDatetime = DateTime.Now; category.UpdatedDatetime = DateTime.Now; _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("Companyid,CeoName,CompanyName,PostCode,Country,Province,City,Address,Address2,OfficePhone,OfficePhone1,OfficePhone2,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Company company) { if (ModelState.IsValid) { company.CreatedDatetime = DateTime.Now; company.UpdatedDatetime = DateTime.Now; _context.Add(company); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(company)); }
public async Task <IActionResult> Create([Bind("Cardid,Userid,Cardnumber,Cardholder,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Creditcard creditcard) { if (ModelState.IsValid) { creditcard.CreatedDatetime = DateTime.Now; creditcard.UpdatedDatetime = DateTime.Now; _context.Add(creditcard); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Userid"] = new SelectList(_context.User, "Userid", "DisplayName", creditcard.Userid); return(View(creditcard)); }
public async Task <IActionResult> Create([Bind("Eventid,Eventname,Startdate,Enddate,RegisterUserid,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Event @event) { if (ModelState.IsValid) { @event.CreatedDatetime = DateTime.Now; @event.UpdatedDatetime = DateTime.Now; _context.Add(@event); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(AdminIndex))); } ViewData["RegisterUserid"] = new SelectList(_context.User, "Userid", "DisplayName", @event.RegisterUserid); return(View(@event)); }
public async Task <IActionResult> Create([Bind("Eventgameid,Eventid,Gameid,DiscountRate,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Eventgame eventgame) { if (ModelState.IsValid) { eventgame.CreatedDatetime = DateTime.Now; eventgame.UpdatedDatetime = DateTime.Now; _context.Add(eventgame); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(eventgame)); }
public async Task <IActionResult> Create([Bind("Wishlistid,Userid,Gameid,Access,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Wishlist wishlist) { if (ModelState.IsValid) { wishlist.CreatedDatetime = DateTime.Now; wishlist.UpdatedDatetime = DateTime.Now; _context.Add(wishlist); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Gameid"] = new SelectList(_context.Game, "Gameid", "Title", wishlist.Gameid); ViewData["UserId"] = _HttpContextAccessor.HttpContext.Session.GetString("Userid"); return(View(wishlist)); }
public async Task <IActionResult> Create([Bind("Favoritid,Userid,Categoryid,Platformid,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Favorite favorite) { if (ModelState.IsValid) { favorite.CreatedDatetime = DateTime.Now; favorite.UpdatedDatetime = DateTime.Now; _context.Add(favorite); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Categoryid"] = new SelectList(_context.Category, "Categoryid", "Categoriname", favorite.Categoryid); ViewData["Favoritid"] = new SelectList(_context.User, "Userid", "DisplayName", favorite.Favoritid); ViewData["Platformid"] = new SelectList(_context.Platform, "Platformid", "Platformname", favorite.Platformid); return(View(favorite)); }
public async Task <IActionResult> Create([Bind("Gameid,Title,Companyid,Price,LaunchDate,Platformid,Categoryid,Description,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Game game) { if (ModelState.IsValid) { game.CreatedDatetime = DateTime.Now; game.UpdatedDatetime = DateTime.Now; _context.Add(game); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Categoryid"] = new SelectList(_context.Category, "Categoryid", "Categoriname", game.Categoryid); ViewData["Companyid"] = new SelectList(_context.Company, "Companyid", "CompanyName", game.Companyid); ViewData["Platformid"] = new SelectList(_context.Platform, "Platformid", "Platformname", game.Platformid); return(View(game)); }
public async Task <IActionResult> Create([Bind("Rateid,Userid,Gameid,Rates,Description,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] Gamerates gamerates) { if (ModelState.IsValid) { gamerates.CreatedDatetime = DateTime.Now; gamerates.UpdatedDatetime = DateTime.Now; gamerates.pending = true; _context.Add(gamerates); await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Game", new { id = gamerates.Gameid })); } ViewData["Gameid"] = new SelectList(_context.Game, "Gameid", "Title", gamerates.Gameid); ViewData["Userid"] = new SelectList(_context.User, "Userid", "DisplayName", gamerates.Userid); return(View(gamerates)); }
public async Task <IActionResult> AddFriend(decimal userID, decimal friendID) { Friends friends = new Friends(); if (ModelState.IsValid) { friends.Userid = userID; friends.FriendUserid = friendID; friends.CreatedDatetime = DateTime.Now; friends.UpdatedDatetime = DateTime.Now; _context.Add(friends); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Create))); } TempData["Message"] = "Error Adding Friend"; return(RedirectToAction(nameof(Create))); }
public async Task <IActionResult> ResetPassword(ResetPasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var users = _context.User.Where(c => c.Email == model.Email); if (users.Any()) { try { User editUser = null; foreach (var u in users as IEnumerable <User> ) { if (u.Password.Equals(model.CurrentPassword)) { editUser = u; } } if (editUser != null) { editUser.UpdatedDatetime = DateTime.Now; editUser.Password = model.Password; _context.Update(editUser); await _context.SaveChangesAsync(); //sendMail(editUser.Email, editUser.Password); TempData["Message"] = "Password Changed"; return(RedirectToAction("Index", "Home")); } } catch (DbUpdateConcurrencyException) { if (!UserExists(model.Email)) { return(NotFound()); } else { throw; } } } // Don't reveal that the user does not exist TempData["Message"] = "Incorrect Email or Password"; return(RedirectToAction("ResetPassword", "Access")); }
public async Task <IActionResult> Create([Bind("Userid,DisplayName,StartDate,EndDate,TryCount,LockDatetime,Password,Usertype,ReceiveEmail,Email,FirstName,LastName,Gender,BirthDate,PostCode,Country,Province,City,Address,Address2,CellPhone,HomePhone,OfficePhone,CreatedDatetime,CreatedUserid,UpdatedDatetime,UpdatedUserid")] User user) { ViewBag.Message = ""; if (ModelState.IsValid) { var displayCheck = await _context.User .FirstOrDefaultAsync(m => m.DisplayName == user.DisplayName); if (displayCheck != null) { ViewBag.Message = "Display Name already exists"; return(View(user)); } var ux = await _context.User .FirstOrDefaultAsync(m => m.Email == user.Email); if (ux != null) { ViewBag.Message = "Email already exists"; return(View(user)); } user.StartDate = DateTime.Now; user.CreatedDatetime = DateTime.Now; user.UpdatedDatetime = DateTime.Now; _context.Add(user); await _context.SaveChangesAsync(); loginUser(user.Email, user.Password); return(RedirectToAction(nameof(Index), "Home")); } return(View(user)); }