Ejemplo n.º 1
0
        //
        // GET: /Users/Create
        // GET: /Signup

        public ActionResult Create()
        {
            if (Request.IsAuthenticated) return RedirectToAction("Dashboard", "Home");

            User user = new User();

            return View(user);
        } 
Ejemplo n.º 2
0
        public ActionResult Create(User user)
        {
            if (Request.IsAuthenticated) return RedirectToAction("Dashboard", "Home");

            user.DateCreated = DateTime.Now;
            user.IsAdmin = false;

            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();

                TempData["success"] = "Welcome to the Project Management App!";
                FormsAuthentication.SetAuthCookie(user.Id.ToString(), false);
                // Session["CurrentUser"] = user;
                return RedirectToAction("Dashboard", "Home");
            }

            return View(user);
        }
Ejemplo n.º 3
0
 public static void SignIn(User user)
 {
     FormsAuthentication.SetAuthCookie(user.Id.ToString(), false);
     HttpContext.Current.Session["current_user"] = user;
 }