예제 #1
0
        public JsonResult submitUserPageTopbar(string id)
        {
            IEnumerable<string> headerValues = Request.Headers.GetValues("Authorization");
            String guid = headerValues.FirstOrDefault();
            guid = guid.Replace("/", "");
            CPSession retVal = TokenManager.getSessionInfo(guid);
            string userName = retVal.getAttributeValue("userName");

            var _db = new ZestorkContainer();
            var UserPageTheme = _db.UserPageSettings.SingleOrDefault(x => x.Username == userName);
            if (UserPageTheme == null)
            {
                UserPageTheme = new UserPageSetting
                {
                    Username = userName,
                    TopBar = id
                };
                _db.UserPageSettings.Add(UserPageTheme);
            }
            else
            {
                UserPageTheme.TopBar = id;
            }

            try
            {
                _db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                dbContextException dbContextException = new CommonMethods.dbContextException();
                dbContextException.logDbContextException(e);
                return Json(500, JsonRequestBehavior.AllowGet);
            }
            return Json(200, JsonRequestBehavior.AllowGet);
        }
예제 #2
0
        public JsonResult details(string id)
        {
            IEnumerable<string> headerValues = Request.Headers.GetValues("Authorization");
            String guid = headerValues.FirstOrDefault();
            guid = guid.Replace("/", "");
            CPSession retVal = TokenManager.getSessionInfo(guid);
            string userName = retVal.getAttributeValue("userName");

            var _db = new ZestorkContainer();
            detailsEditUserPage detailsEditUserPage = new detailsEditUserPage();
            Users user = _db.Users.SingleOrDefault(x => x.Username == userName && x.isActive == "true");
            bool Autherized = true;
            UserPageSetting pageSetting = _db.UserPageSettings.SingleOrDefault(x => x.Username == userName);
            if (user.Locked == "true")
            {
                //Response.Redirect("/Locked/index/"+guid);
            }

            if (user.Type == "user" || user.Type == "NA")
            {
                Autherized = false;
            }
            detailsEditUserPage.Username = user.Username;
            detailsEditUserPage.isActive = user.isActive;
            detailsEditUserPage.Type = user.Type;
            detailsEditUserPage.Source = user.Source;
            detailsEditUserPage.guid = user.guid;
            detailsEditUserPage.FirstName = user.FirstName;
            detailsEditUserPage.LastName = user.LastName;
            detailsEditUserPage.ImageUrl = user.ImageUrl;
            detailsEditUserPage.gender = user.gender;
            detailsEditUserPage.Locked = Convert.ToBoolean(user.Locked);
            if (user.KeepMeSignedIn != null && user.KeepMeSignedIn == "true")
                detailsEditUserPage.keepMeSignedIn = true;
            else
                detailsEditUserPage.keepMeSignedIn = false;
            if (pageSetting == null)
            {
                pageSetting = new UserPageSetting();
            }
            if (pageSetting.PageThemeColor != null)
                detailsEditUserPage.PageThemeColor = "theme-" + pageSetting.PageThemeColor;
            else
                detailsEditUserPage.PageThemeColor = "";

            if (pageSetting.LayoutWidth != null)
                detailsEditUserPage.pageLayoutWidth = pageSetting.LayoutWidth;
            else
                detailsEditUserPage.pageLayoutWidth = "container-fluid";

            if (pageSetting.TopBar != null)
                detailsEditUserPage.pageTopbar = pageSetting.TopBar;
            else
                detailsEditUserPage.pageTopbar = "";

            if (pageSetting.SideBar != null)
                detailsEditUserPage.pageSidebar = pageSetting.SideBar;
            else
                detailsEditUserPage.pageSidebar = "Default";

            detailsEditUserPage.skillTags = _db.UserSkills.Where(x => x.Username == userName).Select(x => x.Skill).ToList();
            if (detailsEditUserPage.ImageUrl == "NA" || detailsEditUserPage.ImageUrl == null)
                detailsEditUserPage.ImageUrl = "../../Resource/templates/afterLogin/web/img/demo/user-avatar.jpg";
            return Json(new { details = detailsEditUserPage, Autherized = Autherized }, JsonRequestBehavior.AllowGet);
        }