Exemple #1
0
 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;
 }
Exemple #2
0
 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));
 }
Exemple #3
0
        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));
            }
        }
Exemple #4
0
        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();
        }
Exemple #5
0
        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());
        }
Exemple #6
0
        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));
        }
Exemple #7
0
 public CompaniesController(AspNetDbContext context, UserManager <AspNetUser> userManager, SignInManager <AspNetUser> signInManager, IEmailSender emailSender, ILogger <AuthController> logger) : base(context, userManager, signInManager, emailSender, logger)
 {
 }
Exemple #8
0
 public ScriptInputParametersController(AspNetDbContext context, UserManager <AspNetUser> userManager, SignInManager <AspNetUser> signInManager, IEmailSender emailSender, ILogger <AuthController> logger) : base(context, userManager, signInManager, emailSender, logger)
 {
 }
Exemple #9
0
 public AspNetRolePermissionsController(AspNetDbContext context, UserManager <AspNetUser> userManager, SignInManager <AspNetUser> signInManager, IEmailSender emailSender, ILogger <AuthController> logger) : base(context, userManager, signInManager, emailSender, logger)
 {
 }