Exemple #1
0
        public async Task <ActionResult> Index(LoginViewmodel model)
        {
            if (ModelState.IsValid)
            {
                kite = new KiteConnect.Kite(APIKey: model.ApiKey, Debug: true);

                User user             = kite.GenerateSession(model.RequestToken, model.ApiSecret);
                var  userSessionModel = new UserSessionModel()
                {
                    AccessToken = user.AccessToken,
                    ApiKey      = model.ApiKey,
                    AppSecret   = model.ApiSecret,
                    UserId      = model.ZerodhaUserId,
                    PublicToken = user.PublicToken
                };
                await _userSessionService.SetCurrentSession(userSessionModel);

                Session["userSession"] = userSessionModel;
                return(RedirectToAction("Index", "Home"));
            }
            ModelState.AddModelError("Something went wrong", "please contact admin");
            return(View(model));
        }