예제 #1
0
        // GET: /<controller>/
        public async Task <IActionResult> Index()
        {
            try
            {
                // GET SESSIONS
                SessionController sessionController = new SessionController();
                SessionBO         session           = sessionController.GetSession(HttpContext.Session);

                ApiRequest apiRequest = new ApiRequest();
                ResponseBO _res       = await apiRequest.GetAsync("User/Profile", session.SessionCookies);

                UserResponseBO apiResponse = JsonConvert.DeserializeObject <UserResponseBO>(_res.ResponseResult);

                TblUserInfo userInfo = apiResponse.UserInfo;
                TblUserAuth userAuth = apiResponse.UserAuth;

                if (apiResponse.HttpStatusCode == "200")
                {
                    GenealogyVM genealogyVM = new GenealogyVM();
                    genealogyVM.Fullname = String.Format("{0} {1}", userInfo.FirstName, userInfo.LastName);
                    genealogyVM.Username = userAuth.UserName;

                    return(View(genealogyVM));
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (System.Exception e)
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
예제 #2
0
        public IActionResult Logout()
        {
            SessionController sessionController = new SessionController();

            sessionController.DestroySession(HttpContext.Session);

            return(Redirect("~/Login"));
        }
예제 #3
0
        public async Task <IActionResult> LoginAsync([FromBody] UserBO userBO)
        {
            try
            {
                ApiRequest apiRequest = new ApiRequest();
                ResponseBO _res       = await apiRequest.PostAsync("User/Authenticate", userBO);

                UserResponseBO apiResponse = JsonConvert.DeserializeObject <UserResponseBO>(_res.ResponseResult);

                if (apiResponse.HttpStatusCode == "200")
                {
                    SessionController sessionController = new SessionController();
                    sessionController.CreateSession(apiResponse, _res.ResponseCookies, HttpContext.Session);

                    TblUserInfo tblUserInfo = apiResponse.UserInfo;
                    TblUserAuth tblUserAuth = apiResponse.UserAuth;
                    TblUserRole tblUserRole = apiResponse.UserRole;



                    //if (tblUserRole.AccessRole.Equals("Admin") || tblUserRole.AccessRole.Equals("SuperAdmin"))
                    //{
                    //    apiResponse.RedirectUrl = "/Admin/";
                    //}
                    //else
                    //{
                    //    apiResponse.RedirectUrl = "/Dashboard/";
                    //}
                    apiResponse.RedirectUrl = "/Dashboard/";
                    return(Ok(apiResponse));
                }
                else
                {
                    apiResponse.RedirectUrl = "/User/Login/Failed";
                    return(BadRequest(apiResponse));
                }
            }
            catch (System.Exception e)
            {
                UserResponseBO apiResponse = new UserResponseBO();
                apiResponse.RedirectUrl = "/User/Login/Failed";
                apiResponse.Message     = e.Message;
                return(BadRequest(apiResponse));
                //return Redirect("~/User/Login/Failed");
            }
        }
예제 #4
0
        // GET: /<controller>/
        public async Task <IActionResult> Index()
        {
            try
            {
                // GET SESSIONS
                SessionController sessionController = new SessionController();
                SessionBO         session           = sessionController.GetSession(HttpContext.Session);

                ApiRequest apiRequest = new ApiRequest();
                ResponseBO _res       = await apiRequest.GetAsync("User/Profile", session.SessionCookies);

                UserResponseBO apiResponse = JsonConvert.DeserializeObject <UserResponseBO>(_res.ResponseResult);

                TblUserInfo userInfo = apiResponse.UserInfo;
                TblUserAuth userAuth = apiResponse.UserAuth;

                _res = await apiRequest.GetAsync("User/Wallet", session.SessionCookies);

                apiResponse = JsonConvert.DeserializeObject <UserResponseBO>(_res.ResponseResult);

                List <UserWalletBO> userWallets = apiResponse.UserWallet;

                if (apiResponse.HttpStatusCode == "200")
                {
                    DashboardVM dashboardVM = new DashboardVM();
                    dashboardVM.Fullname          = String.Format("{0} {1}", userInfo.FirstName, userInfo.LastName);
                    dashboardVM.TotalCustomer     = (int)userWallets.Find(i => i.WalletCode == "DLN").Balance;
                    dashboardVM.TotalFirstDeposit = (int)userWallets.Find(i => i.WalletCode == "IDC").Balance;
                    dashboardVM.TotalHits         = (int)userWallets.Find(i => i.WalletCode == "HIT").Balance;
                    dashboardVM.TotalIncome       = (int)userWallets.Find(i => i.WalletCode == "TIN").Balance;
                    dashboardVM.TotalSignUps      = (int)userWallets.Find(i => i.WalletCode == "TCR").Balance;
                    dashboardVM.Username          = userAuth.UserName;

                    return(View(dashboardVM));
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (System.Exception e)
            {
                return(RedirectToAction("Login", "Home"));
            }
        }