public IActionResult LogInSyn([FromBody] DTO.Principal principal)
        {
            PrincipalDAO dao  = new PrincipalDAO(_context);
            string       role = dao.CheckLogin(principal.Username, principal.Password);

            if (role == "admin" || role == "user")
            {
                HttpContext.Session.SetString("USER", principal.Username);
                HttpContext.Session.SetString("ROLE", role);
                if (role == "user")
                {
                    ShoppingCartDAO      scDAO              = new ShoppingCartDAO(_context);
                    List <DTO.Accessory> listAccCart        = scDAO.FindAllAccCartByUsername(principal.Username);
                    Dictionary <string, DTO.Accessory> cart = new Dictionary <string, DTO.Accessory>();
                    foreach (var item in listAccCart)
                    {
                        DTO.ShoppingCart.AddCart(item, cart);
                    }
                    HttpContext.Session.SetCollectionAsJson("cart", cart);
                }
                TempData["msg"]         = "Register successful";
                TempData["msg-details"] = "System automatically log in your account.";
            }
            else
            {
                TempData["msg"] = "Register failed";
            }
            return(RedirectToAction("Index", "Home"));;
        }
        public IActionResult LogIn([FromBody] DTO.Principal principal)
        {
            PrincipalDAO dao  = new PrincipalDAO(_context);
            string       role = dao.CheckLogin(principal.Username, principal.Password);

            if (role == "admin" || role == "user")
            {
                HttpContext.Session.SetString("USER", principal.Username);
                HttpContext.Session.SetString("ROLE", role);
                if (role == "user")
                {
                    ShoppingCartDAO      scDAO              = new ShoppingCartDAO(_context);
                    List <DTO.Accessory> listAccCart        = scDAO.FindAllAccCartByUsername(principal.Username);
                    Dictionary <string, DTO.Accessory> cart = new Dictionary <string, DTO.Accessory>();
                    foreach (var item in listAccCart)
                    {
                        DTO.ShoppingCart.AddCart(item, cart);
                    }
                    HttpContext.Session.SetCollectionAsJson("cart", cart);
                    var a = HttpContext.Session.GetCollectionFromJson <Dictionary <string, DTO.Accessory> >("cart");
                }
                TempData["msg"] = "Login successfully";
            }
            else
            {
                TempData["msg"] = "Login failed";
            }
            return(new JsonResult(role));
        }