public ActionResult Register(string userName, string password, string firstName, string lastName) { List <User> users = db.Users.ToList(); for (int i = 0; i < users.Count; i++) { User u = users[i]; if (u.UserName.Equals(userName)) { ViewData["Message"] = "That user already exists. Please try again!"; return(View()); } } if (ModelState.IsValid) { var dataInput = new User { UserName = userName, Password = password, FirstName = firstName, LastName = lastName }; db.Add(dataInput); db.SaveChanges(); ViewData["Message"] = "Successfully Created."; return(View()); } return(View()); }
public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Price")] Movie movie) { if (ModelState.IsValid) { _context.Add(movie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> Create([Bind("Mid,Mname,StarCast,Producer,Director,ReleaseDate")] Movie movie) { if (ModelState.IsValid) { _context.Add(movie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> Create([Bind("movieID,category,title,year,director,rating,edited,lent,notes")] Movie movie) { if (ModelState.IsValid) { _context.Add(movie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public IActionResult AddToFavorites(string Title) { string userName = Request.Cookies["userNameCookie"]; int userId; if (userName != null) { userId = GetUserId(userName); Movies MyMovie = MoviesDAL.FindTitleAPI(Title); var dataInput = new Movies { imdbID = MyMovie.imdbID, UserId = userId, Plot = MyMovie.Plot, Rated = MyMovie.Rated, Title = MyMovie.Title, Year = MyMovie.Year }; db.Add(dataInput); db.SaveChanges(); return(RedirectToAction("Search")); } else { ViewData["Message"] = "You are not Logged in! try again"; return(RedirectToAction("Login", "Login")); } }