Exemple #1
0
        public ActionResult AdminDashboard()
        {
            Frontend.APIDTO.APIUserInformation userInfo = (Frontend.APIDTO.APIUserInformation)Session[Frontend.Customize.Common.ProjectDefinition.USER_INFO_SESSION];
            if (userInfo.Data.UserGroupID != 1) // not belong to admin group
            {
                return(RedirectToAction("UserDashboard"));
            }

            ViewBag.CurrentLoginUserInfo = userInfo;
            ViewBag.Token = Session[Frontend.Customize.Common.ProjectDefinition.TOKEN_SESSION];
            return(View());
        }
Exemple #2
0
        public ActionResult Index()
        {
            if (Session[Frontend.Customize.Common.ProjectDefinition.USER_INFO_SESSION] == null || Session[Frontend.Customize.Common.ProjectDefinition.TOKEN_SESSION] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            Frontend.APIDTO.APIUserInformation userInfo = (Frontend.APIDTO.APIUserInformation)Session[Frontend.Customize.Common.ProjectDefinition.USER_INFO_SESSION];
            ViewBag.CurrentLoginUserInfo = userInfo;
            ViewBag.ModuleCode           = ModuleCode;
            return(View());
        }
Exemple #3
0
        public ActionResult Index()
        {
            if (Session[Frontend.Customize.Common.ProjectDefinition.USER_INFO_SESSION] == null || Session[Frontend.Customize.Common.ProjectDefinition.TOKEN_SESSION] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            Frontend.APIDTO.APIUserInformation userInfo = (Frontend.APIDTO.APIUserInformation)Session[Frontend.Customize.Common.ProjectDefinition.USER_INFO_SESSION];
            //if (userInfo.Data.CompanyID == 2) // auvietsoft company
            //{
            //    return RedirectToAction("ASVDashboard");
            //}
            if (userInfo.Data.UserGroupID == 1)
            {
                return(RedirectToAction("AdminDashboard"));
            }

            return(RedirectToAction("UserDashboard"));
        }
        public ActionResult SwitchBranch(int b)
        {
            using (var client = new WebClient())
            {
                client.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + Session[Customize.Common.ProjectDefinition.TOKEN_SESSION].ToString());
                client.Headers.Add(HttpRequestHeader.Accept, "application/json");
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");

                // send request get all items
                try
                {
                    string url          = System.Configuration.ConfigurationManager.AppSettings["BackendServiceUrl"].ToString() + "api/account/switch-branch?branchId=" + b.ToString();
                    var    anonymousObj = new { access_token = "", expires_in = 0 };

                    // get new token from api service
                    var obj = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(client.DownloadString(url), anonymousObj);

                    // registering new user info into session
                    Session[Customize.Common.ProjectDefinition.TOKEN_SESSION] = obj.access_token;
                    Frontend.APIDTO.APIUserInformation currentUserInfo = (Frontend.APIDTO.APIUserInformation)Session[Customize.Common.ProjectDefinition.USER_INFO_SESSION];
                    currentUserInfo.Data.BranchID = b;
                    currentUserInfo.Data.BranchUD = currentUserInfo.Data.Branches.FirstOrDefault(o => o.BranchID == b).BranchUD;
                    Session[Customize.Common.ProjectDefinition.USER_INFO_SESSION] = currentUserInfo;
                }
                catch (WebException exception)
                {
                    //string responseText = string.Empty;
                    //var responseStream = exception.Response?.GetResponseStream();
                    //if (responseStream != null)
                    //{
                    //    using (var reader = new StreamReader(responseStream))
                    //    {
                    //        responseText = reader.ReadToEnd();
                    //    }
                    //}
                    //throw new Exception("getEUData: " + responseText);
                }
                return(RedirectToAction("Index", "DashBoard", new object()
                {
                }));
                //JObject data = (JObject)obj.ToObject();
            }
        }
Exemple #5
0
 public static APIDTO.APIUserInformation GetCurrentUserInfo(HttpContext currentContext)
 {
     Frontend.APIDTO.APIUserInformation userInfo = (Frontend.APIDTO.APIUserInformation)currentContext.Session[Frontend.Customize.Common.ProjectDefinition.USER_INFO_SESSION];
     return(userInfo);
 }