public async Task <IActionResult> Login(User user)
        {
            if (ModelState.IsValid)
            {
                var resultToken = _accountAgent.GetToken(user);
                if (resultToken.Success)
                {
                    //HttpContext.Session.Set(Constants.SessionKeyState, token.objectResult);
                    //user.Token = token.objectResult;
                    var result = await _signInManager.PasswordSignInAsync(user.Username, user.Password, false, lockoutOnFailure : false);

                    if (result.Succeeded)
                    {
                        var userData      = _accountAgent.GetUserByCredentials(user.Username, user.Password, resultToken.objectResult).objectResult;
                        var userId        = userData.Id;
                        var establishment = _establishmentAgent.GetEstablishmentById(userId);

                        if (establishment.Success)
                        {
                            userData.Establishment = establishment.objectResult;
                            var menu = _accountAgent.GetModulesByUserId(userId, null);

                            if (menu.Success)
                            {
                                userData.Modules = menu.objectResult;
                            }
                        }
                        else
                        {
                            HttpContext.Session.Set(Constants.SessionKeyState, userData);
                            return(await Task.FromResult(RedirectToAction("NewEstablishment", "Establishment")));
                        }

                        //this.User.GetUserId();
                        HttpContext.Session.Set(Constants.SessionKeyState, userData);
                        return(await Task.FromResult(RedirectToAction("Dashboard", "Book")));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid credentials");
                    }
                }
            }
            return(await Task.FromResult(View(user)));
        }
        public ActionResult Profile()
        {
            var user = HttpContext.Session.Get <User>(Constants.SessionKeyState);

            ViewBag.Email = user.Email;
            ViewBag.Logo  = user.Establishment.Logo.Uri;
            var userId = user.Id;
            var result = _establishmentAgent.GetEstablishmentById(userId);

            if (result.Success)
            {
                user.Establishment = result.objectResult;
                var menu = _accountAgent.GetModulesByUserId(userId, null);
                if (menu.Success)
                {
                    user.Modules = menu.objectResult;
                }

                return(View(result.objectResult));
            }

            return(RedirectToAction("NewEstablishment", "Establishment"));
        }