Esempio n. 1
0
        public IActionResult DetailAccount(int id)
        {
            DEntity <AccountDetail> e   = new DEntity <AccountDetail>(ConstValue.ConnectionString, AccountDetail.getTableName());
            AccountDetail           lst = e.get("iduser", id);

            return(View(lst));
        }
        public IActionResult Login(UserLoginModel userModel, string returnUrl = null)
        {
            try
            {
                // Verification.
                if (ModelState.IsValid)
                {
                    List <Account> lst      = AccountRes.GetAll();
                    string         usertemp = "";
                    for (int i = 0; i < lst.Count; i++)
                    {
                        if ((lst[i].username == userModel.Username) && (lst[i].password == userModel.Password))
                        {
                            usertemp = lst[i].username;
                            DEntity <AccountDetail> e         = new DEntity <AccountDetail>(ConstValue.ConnectionString, AccountDetail.getTableName());
                            AccountDetail           lstDetail = e.get("iduser", lst[i].id);
                            this.SignInUser(lst[i].id, lst[i].groupId, lst[i].username, lstDetail.name, userModel.RememberMe);

                            Console.WriteLine("user", User.Identity.Name);
                            //Console.WriteLine("userdata", claims[1].Value);
                            Console.WriteLine("user", User.Identity.AuthenticationType);
                            return(this.RedirectToAction("Index", "HomeDrugstore"));
                        }
                    }
                    if (usertemp == "")
                    {
                        ModelState.AddModelError(string.Empty, "Invalid username or password.");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            // If we got this far, something failed, redisplay form
            return(this.View(userModel));
        }