Exemplo n.º 1
0
        public IActionResult RegisterUser(User user)
        {
            _DataContext.Users.Add(user);
            _DataContext.SaveChanges();

            return(RedirectToAction("Login"));
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        ///
        public IActionResult CreateBlogPost(BlogPost movie)
        {
            _movieContext.BlogPosts.Add(movie);
            _movieContext.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public IActionResult RegisterUser(User user)
        {
            if (ModelState.IsValid)
            {
                _assignment1DataContext.Users.Add(user);
                _assignment1DataContext.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        public IActionResult DisplayFullBlogPost()
        {
            Comment comment = new Models.Comment();

            comment.BlogPostId = Convert.ToInt32(Request.Form["BlogPostId"]);
            comment.UserId     = Convert.ToInt32(HttpContext.Session.GetString("UserId"));
            comment.Content    = Request.Form["Comment.Content"];

            _assign1Context.Comment.Add(comment);
            _assign1Context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
 public IActionResult addUser(User user)
 {
     if (user.FirstName != null && user.LastName != null && user.EmailAddress != null && user.Password != null && user.RoleId != 0)
     {
         user.Password = CalculateMD5Hash(user.Password);
         _BlogPostContext.Users.Add(user);
         if (_BlogPostContext.SaveChanges() == 1)
         {
             return(RedirectToAction("Login"));
         }
     }
     return(RedirectToAction("Register", user));
 }
        public IActionResult RegisterUser(User user)
        {
            if (Request.Form["Name"] == "Admin")
            {
                user.RoleId = 2;
            }
            else
            {
                user.RoleId = 1;
            }

            // Add new user
            dataContext.Users.Add(user);
            // Save database changes
            dataContext.SaveChanges();
            // Redirect to the login page
            return(RedirectToAction("Login"));
        }
Exemplo n.º 7
0
 public IActionResult CreateUser(User user)
 {
     _context.Users.Add(user);
     _context.SaveChanges();
     return(RedirectToAction("Login"));
 }