public ActionResult DoLogin(User model)
        {
            var user = service.Login(model.UserName, model.Password);
            if (user != null)
            {
                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(model.UserName, false, 1);
                string encriptTicket = FormsAuthentication.Encrypt(authTicket);
                HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encriptTicket);
                Response.Cookies.Add(authCookie);
                HttpContext.Application.Add("USER", user);

                return RedirectToAction("Welcome", "home");
            }
            else
            {
                ModelState.AddModelError("", "Usuário ou Senha incorretos.");
                return View("Login", model);
            }
        }
 public ActionResult CreateUser(User model)
 {
     service.CreateUser(model);
     return RedirectToAction("ListUsers");
 }
예제 #3
0
 public void DeleteUser(User user)
 {
     new GenericRepository<User>().Delete(user);
 }
예제 #4
0
 public void UpdateUser(User user)
 {
     new GenericRepository<User>().Update(user);
 }
예제 #5
0
 public void CreateUser(User user)
 {
     new GenericRepository<User>().Create(user);
 }