public ApiController(AspNetDbContext context, UserManager <AspNetUser> userManager, SignInManager <AspNetUser> signInManager, IEmailSender emailSender, ILogger <AuthController> logger) { DB = context; UserManager = userManager; SignInManager = signInManager; EmailSender = emailSender; Logger = logger; }
public IActionResult Register(User model) { if (ModelState.IsValid) { using (var db = new AspNetDbContext()) { db.Users.Add(model); db.SaveChanges(); } return(RedirectToAction("Index", "Home")); } return(View(model)); }
public IActionResult Index() { if (HttpContext.Session.GetInt32("USER_LOGIN_KEY") == null) { return(RedirectToAction("Login", "Account")); } //var list = new List<Note>(); using (var db = new AspNetDbContext()) { var list = db.Notes.ToList(); return(View(list)); } }
public IActionResult Detail(int noteNo) { if (HttpContext.Session.GetInt32("USER_LOGIN_KEY") == null) { return(RedirectToAction("Login", "Account")); } using (var db = new AspNetDbContext()) { var note = db.Notes.FirstOrDefault(n => n.NoteNo.Equals(noteNo)); return(View(note)); } //return View(); }
public IActionResult Login(LoginUserModel model) { if (ModelState.IsValid) { using (var db = new AspNetDbContext()) { // Linq 쿼리식 - 메서드 체이닝으로 var user = db.Users.FirstOrDefault(u => u.UserId.Equals(model.UserId) && u.UserPassword.Equals(model.UserPassword)); //람다식으로 가져옴 if (user != null) //로그인 성공 { //HttpContext.Session.SetInt32(key, value); HttpContext.Session.SetInt32("USER_LOGIN_KEY", user.UserNo); return(RedirectToAction("LoginSuccess", "Home")); } else //로그인 실패 { ModelState.AddModelError(string.Empty, "사용자 ID 혹은 비번이 틀렸음"); } } } return(View()); }
public IActionResult Add(Note model) { if (HttpContext.Session.GetInt32("USER_LOGIN_KEY") == null) { return(RedirectToAction("Login", "Account")); } model.UserNo = int.Parse(HttpContext.Session.GetInt32("USER_LOGIN_KEY").ToString()); if (ModelState.IsValid) { using (var db = new AspNetDbContext()) { db.Notes.Add(model); if (db.SaveChanges() > 0) //commit 결과가 성공일 경우 { return(Redirect("Index")); //동일한 컨트롤러 내의 리다이렉트는 toaction안해도 ㅇㅋ } ModelState.AddModelError(string.Empty, "게시물 저장 불가"); } } return(View(model)); }
public CompaniesController(AspNetDbContext context, UserManager <AspNetUser> userManager, SignInManager <AspNetUser> signInManager, IEmailSender emailSender, ILogger <AuthController> logger) : base(context, userManager, signInManager, emailSender, logger) { }
public ScriptInputParametersController(AspNetDbContext context, UserManager <AspNetUser> userManager, SignInManager <AspNetUser> signInManager, IEmailSender emailSender, ILogger <AuthController> logger) : base(context, userManager, signInManager, emailSender, logger) { }
public AspNetRolePermissionsController(AspNetDbContext context, UserManager <AspNetUser> userManager, SignInManager <AspNetUser> signInManager, IEmailSender emailSender, ILogger <AuthController> logger) : base(context, userManager, signInManager, emailSender, logger) { }