Esempio n. 1
0
        public ActionResult GetAllWords()
        {
            var httpContext = _accessor.HttpContext;

            _member = httpContext.Session.GetString("_member");

            if (!string.IsNullOrEmpty(_member))
            {
                //Checking token for request
                if (_tokenhelper.CheckToken())
                {
                    _token = httpContext.Session.GetString("_token");
                }
                else
                {
                    Task <string> result = _tokenhelper.CreateToken();
                    result.Wait();
                    _token = result.Result;
                }

                Task <WordsViewModelByWebApi> vocabularyList = _webApiHelper.GetWordsByWebApi(_token);
                vocabularyList.Wait();

                return(Json(new { success = true, data = vocabularyList.Result }));
            }
            else
            {
                return(Json(new { success = false }));
            }
        }
Esempio n. 2
0
        public ActionResult Authentication(MemberViewModel request)
        {
            if (_tokenhelper.CheckToken())
            {
                var httpContext = _accessor.HttpContext;
                _token      = httpContext.Session.GetString("_token");
                httpContext = null;
            }
            else
            {
                Task <string> result = _tokenhelper.CreateToken();
                result.Wait();
                _token = result.Result;
            }

            Task <bool> memberCheck = _loginHelper.LoginMember(request, _token);

            memberCheck.Wait();

            if (memberCheck.Result)
            {
                var httpContext = _accessor.HttpContext;
                httpContext.Session.SetString("_member", "loggedIn");
                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { success = false }));
            }
        }