コード例 #1
0
        public ActionResult EditUser(string UserName)
        {
            // themes : deserialize/send list of themes, plus send active theme, plus send list of tags/keywords
            var userId               = User.Identity.GetUserId();
            var userXtrctThemes      = new Arabizer().loaddeserializeM_XTRCTTHEME_DAPPERSQL(userId);
            var userActiveXtrctTheme = userXtrctThemes.Find(m => m.CurrentActive == "active");

            @ViewBag.UserXtrctThemes  = userXtrctThemes;
            @ViewBag.XtrctThemesPlain = userXtrctThemes.Select(m => new SelectListItem {
                Text = m.ThemeName.Trim(), Selected = m.ThemeName.Trim() == userActiveXtrctTheme.ThemeName.Trim() ? true : false
            });
            @ViewBag.UserActiveXtrctTheme = userActiveXtrctTheme;

            // Fetch the data for fbPages for all themes for that user
            var fbFluencerAsTheme = new Arabizer().loadDeserializeT_FB_INFLUENCERs_DAPPERSQL(userId);

            ViewBag.AllInfluenceVert = fbFluencerAsTheme;

            //
            if (UserName == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExpandedUserDTO objExpandedUserDTO = GetUser(UserName);

            if (objExpandedUserDTO == null)
            {
                return(HttpNotFound());
            }
            return(View(objExpandedUserDTO));
        }
コード例 #2
0
        public ActionResult Create()
        {
            ExpandedUserDTO objExpandedUserDTO = new ExpandedUserDTO();

            ViewBag.Roles = GetAllRolesAsSelectList();

            // themes : deserialize/send list of themes, plus send active theme, plus send list of tags/keywords
            var userId               = User.Identity.GetUserId();
            var userXtrctThemes      = new Arabizer().loaddeserializeM_XTRCTTHEME_DAPPERSQL(userId);
            var userActiveXtrctTheme = userXtrctThemes.Find(m => m.CurrentActive == "active");

            @ViewBag.UserXtrctThemes  = userXtrctThemes;
            @ViewBag.XtrctThemesPlain = userXtrctThemes.Select(m => new SelectListItem {
                Text = m.ThemeName.Trim(), Selected = m.ThemeName.Trim() == userActiveXtrctTheme.ThemeName.Trim() ? true : false
            });
            @ViewBag.UserActiveXtrctTheme = userActiveXtrctTheme;

            return(View(objExpandedUserDTO));
        }
コード例 #3
0
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : "";

            var userId = User.Identity.GetUserId();
            var model  = new IndexViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins            = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
            };

            // needed to not crash vert menu : themes : deserialize/send list of themes, plus send active theme, plus send list of tags/keywords
            var userXtrctThemes      = new Arabizer().loaddeserializeM_XTRCTTHEME_DAPPERSQL(userId);
            var userActiveXtrctTheme = userXtrctThemes.Find(m => m.CurrentActive == "active");

            @ViewBag.UserXtrctThemes  = userXtrctThemes;
            @ViewBag.XtrctThemesPlain = userXtrctThemes.Select(m => new SelectListItem {
                Text = m.ThemeName.Trim(), Selected = m.ThemeName.Trim() == userActiveXtrctTheme.ThemeName.Trim() ? true : false
            });
            @ViewBag.UserActiveXtrctTheme = userActiveXtrctTheme;

            // Fetch the data for fbPages for all themes for that user
            var fbFluencerAsTheme = new Arabizer().loadDeserializeT_FB_INFLUENCERs_DAPPERSQL(userId);

            ViewBag.AllInfluenceVert = fbFluencerAsTheme;

            //
            return(View(model));
        }
コード例 #4
0
        public ActionResult Index(string searchStringUserNameOrEmail, string currentFilter, int?page)
        {
            try
            {
                int intPage           = 1;
                int intPageSize       = 5;
                int intTotalItemCount = 0;

                //
                if (searchStringUserNameOrEmail != null)
                {
                    intPage = 1;
                }
                else if (currentFilter != null)
                {
                    searchStringUserNameOrEmail = currentFilter;
                    intPage = page ?? 1;
                }
                else
                {
                    searchStringUserNameOrEmail = "";
                    intPage = page ?? 1;
                }

                //
                ViewBag.CurrentFilter = searchStringUserNameOrEmail;
                List <ExpandedUserDTO> col_UserDTO = new List <ExpandedUserDTO>();
                int intSkip = (intPage - 1) * intPageSize;

                //
                var users  = UserManager.Users.Where(x => x.UserName.Contains(searchStringUserNameOrEmail));
                var lusers = users.ToList();

                // get register apps to make a join with users and with registerusers to get get last login time
                var registerApps  = new Arabizer().loaddeserializeRegisterApps_DAPPERSQL();
                var registerUsers = new Arabizer().loaddeserializeRegisterUsers_DAPPERSQL();
                var result0       = lusers.Join(registerApps, u => u.Id.ToUpper(), a => a.UserID.ToUpper(), (usr, app) => new
                {
                    app.UserID,
                    usr.UserName,
                    usr.Email,
                    usr.LockoutEndDateUtc,
                    app.TotalAppCallConsumed,
                    app.TotalAppCallLimit
                }).Join(registerUsers, r1 => r1.Email, u => u.EmailID, (res1, regusr) => new
                {
                    res1.UserID,
                    res1.UserName,
                    res1.Email,
                    res1.LockoutEndDateUtc,
                    res1.TotalAppCallConsumed,
                    res1.TotalAppCallLimit,
                    regusr.LastLoginTime
                });

                // themes count for the user
                var xtrctThemesCountPerUser = new Arabizer().loaddeserializeM_XTRCTTHEME_CountPerUser_DAPPERSQL();
                var result1 = result0.Join(xtrctThemesCountPerUser, r => r.UserID.ToUpper(), x => x.UserID.ToUpper(), (res2, xtcpu) => new
                {
                    res2.UserID,
                    res2.UserName,
                    res2.Email,
                    res2.LockoutEndDateUtc,
                    res2.TotalAppCallConsumed,
                    res2.TotalAppCallLimit,
                    res2.LastLoginTime,
                    xtcpu.CountPerUser
                });

                // fb pages count for the user & fb posts count for the user
                List <LM_CountPerTheme> fbPageCountPerTheme     = new Arabizer().loaddeserializeT_FB_INFLUENCER_CountPerTheme_DAPPERSQL();
                List <M_XTRCTTHEME>     xtrctThemes             = new Arabizer().loaddeserializeM_XTRCTTHEME_DAPPERSQL();
                List <LM_CountPerTheme> fbPostsCountPerTheme    = new Arabizer().loaddeserializeT_FB_POST_CountPerTheme_DAPPERSQL();
                List <LM_CountPerTheme> fbCommentsCountPerTheme = new Arabizer().loaddeserializeT_FB_Comments_CountPerTheme_DAPPERSQL();
                var usersToThemesToFbPagesCount = fbPageCountPerTheme.Join(
                    xtrctThemes,
                    fb => fb.fk_theme,
                    xt => xt.ID_XTRCTTHEME.ToString(),
                    (fb, xt) => new
                {
                    fb.fk_theme,
                    fb.CountPerTheme,
                    fkUserID = xt.UserID
                });
                var usersToThemesToFbPagesToFbPostsCount = usersToThemesToFbPagesCount.Join(
                    fbPostsCountPerTheme,
                    u => u.fk_theme,
                    fb => fb.fk_theme,
                    (u, fb) => new
                {
                    u.fk_theme,
                    u.CountPerTheme,
                    u.fkUserID,
                    FBPostsCountPerUser = fb.CountPerTheme
                });
                var usersToThemesToFbPagesToFbPostsToFBCommentsCount = usersToThemesToFbPagesToFbPostsCount.Join(
                    fbCommentsCountPerTheme,
                    u => u.fk_theme,
                    fb => fb.fk_theme,
                    (u, fb) => new
                {
                    u.fk_theme,
                    u.CountPerTheme,
                    u.fkUserID,
                    u.FBPostsCountPerUser,
                    FBCommentsCountPerUser = fb.CountPerTheme
                });
                var result3 = result1.GroupJoin(usersToThemesToFbPagesToFbPostsToFBCommentsCount,
                                                x => x.UserID,
                                                y => y.fkUserID, (x, y) => new
                {
                    x.UserID,
                    x.UserName,
                    x.Email,
                    x.LockoutEndDateUtc,
                    x.TotalAppCallConsumed,
                    x.TotalAppCallLimit,
                    x.LastLoginTime,
                    ThemesCountPerUser     = x.CountPerUser,
                    FBPagesCountPerUser    = y.Sum(m => m.CountPerTheme),
                    FBPostsCountPerUser    = y.Sum(m => m.FBPostsCountPerUser),
                    FBCommentsCountPerUser = y.Sum(m => m.FBCommentsCountPerUser)
                });

                // darija entries count for the user
                var arEntriesCountPerUser = new Arabizer().loaddeserializeM_ARABICDARIJAENTRY_CountPerUser_DAPPERSQL();
                var result = result3.Join(arEntriesCountPerUser,
                                          x => x.UserID,
                                          y => y.UserID, (x, y) => new
                {
                    x.UserID,
                    x.UserName,
                    x.Email,
                    x.LockoutEndDateUtc,
                    x.TotalAppCallConsumed,
                    x.TotalAppCallLimit,
                    x.LastLoginTime,
                    x.ThemesCountPerUser,
                    x.FBPagesCountPerUser,
                    ArEntriesCountPerUser = y.CountPerUser,
                    x.FBPostsCountPerUser,
                    x.FBCommentsCountPerUser
                });

                // items count
                intTotalItemCount = result.Count();

                // take the items for the current page only
                result = result
                         .OrderByDescending(x => x.LastLoginTime)
                         .Skip(intSkip)
                         .Take(intPageSize);

                //
                foreach (var item in result)
                {
                    ExpandedUserDTO objUserDTO = new ExpandedUserDTO();
                    objUserDTO.UserName               = item.UserName;
                    objUserDTO.Email                  = item.Email;
                    objUserDTO.LockoutEndDateUtc      = item.LockoutEndDateUtc;
                    objUserDTO.TotalAppCallLimit      = item.TotalAppCallLimit;
                    objUserDTO.TotalAppCallConsumed   = item.TotalAppCallConsumed;
                    objUserDTO.LastLoginTime          = item.LastLoginTime;
                    objUserDTO.ThemesCountPerUser     = item.ThemesCountPerUser;
                    objUserDTO.FBPagesCountPerUser    = item.FBPagesCountPerUser;
                    objUserDTO.ArEntriesCountPerUser  = item.ArEntriesCountPerUser;
                    objUserDTO.FBPostsCountPerUser    = item.FBPostsCountPerUser;
                    objUserDTO.FBCommentsCountPerUser = item.FBCommentsCountPerUser;
                    col_UserDTO.Add(objUserDTO);
                }

                // Created the paged list and Set the number of pages
                var _UserDTOAsIPagedList = new StaticPagedList <ExpandedUserDTO>(col_UserDTO, intPage, intPageSize, intTotalItemCount);

                // themes : deserialize/send list of themes, plus send active theme, plus send list of tags/keywords
                var userId               = User.Identity.GetUserId();
                var userXtrctThemes      = new Arabizer().loaddeserializeM_XTRCTTHEME_DAPPERSQL(userId);
                var userActiveXtrctTheme = userXtrctThemes.Find(m => m.CurrentActive == "active");
                @ViewBag.UserXtrctThemes  = userXtrctThemes;
                @ViewBag.XtrctThemesPlain = userXtrctThemes.Select(m => new SelectListItem {
                    Text = m.ThemeName.Trim(), Selected = m.ThemeName.Trim() == userActiveXtrctTheme.ThemeName.Trim() ? true : false
                });
                @ViewBag.UserActiveXtrctTheme = userActiveXtrctTheme;

                // Fetch the data for fbPages for all themes for that user
                var fbFluencerAsTheme = new Arabizer().loadDeserializeT_FB_INFLUENCERs_DAPPERSQL(userId);
                ViewBag.AllInfluenceVert = fbFluencerAsTheme;

                //
                return(View(_UserDTOAsIPagedList));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Error: " + ex);
                List <ExpandedUserDTO> col_UserDTO = new List <ExpandedUserDTO>();
                return(View(col_UserDTO.ToPagedList(1, 25)));
            }
        }
コード例 #5
0
        public ActionResult IndexFBs(string searchStringUserNameOrEmail, string currentFilter, int?page)
        {
            int intPage           = 1;
            int intPageSize       = 5;
            int intTotalItemCount = 0;

            //
            if (searchStringUserNameOrEmail != null)
            {
                intPage = 1;
            }
            else if (currentFilter != null)
            {
                searchStringUserNameOrEmail = currentFilter;
                intPage = page ?? 1;
            }
            else
            {
                searchStringUserNameOrEmail = "";
                intPage = page ?? 1;
            }

            //
            ViewBag.CurrentFilter = searchStringUserNameOrEmail;
            int intSkip = (intPage - 1) * intPageSize;

            //
            var users  = UserManager.Users;
            var lusers = users.ToList();

            // themes for the users
            List <M_XTRCTTHEME> xtrctThemes = new Arabizer().loaddeserializeM_XTRCTTHEME_DAPPERSQL();

            // fb pages for the users
            List <T_FB_INFLUENCER> fbPages = new Arabizer().loadDeserializeT_FB_INFLUENCERs_DAPPERSQL();

            //
            var result0 = lusers.Join(xtrctThemes,
                                      x => x.Id.ToUpper(),
                                      y => y.UserID.ToUpper(), (x, y) => new
            {
                y.ThemeName,
                y.CurrentActive,
                x.UserName,
                idXtrctTheme = y.ID_XTRCTTHEME.ToString()
            });

            var result = result0.Join(fbPages,
                                      x => x.idXtrctTheme,
                                      y => y.fk_theme, (x, y) => new FBPageToThemeToUserViewModel
            {
                name = y.name,          // FB page name
                AutoRetrieveFBPostAndComments = y.AutoRetrieveFBPostAndComments,
                ThemeName     = x.ThemeName,
                CurrentActive = x.CurrentActive,
                UserName      = x.UserName
            });

            result = result.Where(x => x.name.ToUpper().Contains(searchStringUserNameOrEmail.ToUpper()));

            // items count
            intTotalItemCount = result.Count();

            // take the items for the current page only
            result = result
                     .OrderByDescending(x => x.name)
                     .Skip(intSkip)
                     .Take(intPageSize);

            // Created the paged list and Set the number of pages
            var pagedList = new StaticPagedList <FBPageToThemeToUserViewModel>(result, intPage, intPageSize, intTotalItemCount);

            // themes : deserialize/send list of themes, plus send active theme, plus send list of tags/keywords
            var userId               = User.Identity.GetUserId();
            var userXtrctThemes      = new Arabizer().loaddeserializeM_XTRCTTHEME_DAPPERSQL(userId);
            var userActiveXtrctTheme = userXtrctThemes.Find(m => m.CurrentActive == "active");

            @ViewBag.UserXtrctThemes  = userXtrctThemes;
            @ViewBag.XtrctThemesPlain = userXtrctThemes.Select(m => new SelectListItem {
                Text = m.ThemeName.Trim(), Selected = m.ThemeName.Trim() == userActiveXtrctTheme.ThemeName.Trim() ? true : false
            });
            @ViewBag.UserActiveXtrctTheme = userActiveXtrctTheme;

            // Fetch the data for fbPages for all themes for that user
            var fbFluencerAsTheme = new Arabizer().loadDeserializeT_FB_INFLUENCERs_DAPPERSQL(userId);

            ViewBag.AllInfluenceVert = fbFluencerAsTheme;

            //
            return(View(pagedList));
        }
コード例 #6
0
        public ActionResult ManageApp(RegisterApp model)
        {
            var userId = User.Identity.GetUserId();

            //
            var keyExists = _clientKeyToolkit.IsUniqueKeyAlreadyGenerate(userId);

            ViewBag.clientExist = keyExists;
            if (keyExists)
            {
                // Getting Generate ClientID and ClientSecret Key By UserID
                ViewBag.clientkeys = _clientKeyToolkit.GetGenerateUniqueKeyByUserID(userId);
            }

            // themes : deserialize/send list of themes, plus send active theme, plus send list of tags/keywords
            var userXtrctThemes = new Arabizer().loaddeserializeM_XTRCTTHEME_DAPPERSQL(userId);
            List <M_XTRCTTHEME_KEYWORD> xtrctThemesKeywords = new Arabizer().loaddeserializeM_XTRCTTHEME_KEYWORD_Active_DAPPERSQL(userId);
            var userActiveXtrctTheme = userXtrctThemes.Find(m => m.CurrentActive == "active");

            @ViewBag.UserXtrctThemes  = userXtrctThemes;
            @ViewBag.XtrctThemesPlain = userXtrctThemes.Select(m => new SelectListItem {
                Text = m.ThemeName.Trim(), Selected = m.ThemeName.Trim() == userActiveXtrctTheme.ThemeName.Trim() ? true : false
            });
            @ViewBag.UserActiveXtrctTheme      = userActiveXtrctTheme;
            @ViewBag.ActiveXtrctThemeNegTags   = xtrctThemesKeywords.Where(m => m.Keyword_Type == "NEGATIVE" || m.Keyword_Type == "OPPOSE" || m.Keyword_Type == "EXPLETIVE" || m.Keyword_Type == "SENSITIVE").ToList();
            @ViewBag.ActiveXtrctThemePosTags   = xtrctThemesKeywords.Where(m => m.Keyword_Type == "POSITIVE" || m.Keyword_Type == "SUPPORT").ToList();
            @ViewBag.ActiveXtrctThemeOtherTags = xtrctThemesKeywords.Where(m => m.Keyword_Type != "POSITIVE" && m.Keyword_Type != "SUPPORT" && m.Keyword_Type != "NEGATIVE" && m.Keyword_Type != "OPPOSE" && m.Keyword_Type != "EXPLETIVE" && m.Keyword_Type != "SENSITIVE").ToList();

            // Fetch the data for fbPages for all themes for that user
            var fbFluencerAsTheme = new Arabizer().loadDeserializeT_FB_INFLUENCERs_DAPPERSQL(userId);

            ViewBag.AllInfluenceVert = fbFluencerAsTheme;

            // working data entries count
            List <LM_CountPerThemePerUser> entriesCountsperThemePerUser = new Arabizer().loaddeserializeM_ARABICDARIJAENTRY_CountPerThemePerUser_DAPPERSQL(userId);

            @ViewBag.EntriesCountsperThemePerUser = entriesCountsperThemePerUser;

            // fb pages comments count
            List <LM_CountPerInfluencer> commentsCountsPerInfluencer = new Arabizer().loaddeserializeT_FB_Comments_CountPerInfluencer_DAPPERSQL(userId);

            @ViewBag.CommentsCountsPerInfluencer = commentsCountsPerInfluencer;

            // fb pages posts count
            List <LM_CountPerInfluencer> postsCountsPerInfluencer = new Arabizer().loaddeserializeT_FB_Posts_CountPerInfluencer_DAPPERSQL(userId);

            @ViewBag.PostsCountsPerInfluencer = postsCountsPerInfluencer;

            // scocial searc posys count & comment count
            @ViewBag.PostsCounts    = new Arabizer().loaddeserializeT_FB_Posts_Count_DAPPERSQL();
            @ViewBag.CommentsCounts = new Arabizer().loaddeserializeT_FB_Comments_Count_DAPPERSQL();

            // GET access (ie : check app dashbord)
            if (Request.HttpMethod.ToUpper() == "GET")
            {
                return(View());
            }

            // check
            if (!ModelState.IsValid)
            {
                return(View("ManageApp", model));
            }

            // check app already registered
            if (_appRegistrar.ValidateAppName(model))
            {
                ModelState.AddModelError("", "App is Already Registered");
                return(View("ManageApp", model));
            }

            // check app already registered
            var app = _appRegistrar.CheckIsAppRegistered(userId);

            if (app == true)
            {
                return(RedirectToAction("Index"));
            }

            // register app model coming from html form
            ClientKeys clientkeys = new AppManager().CreateApp(model, userId, keyExists, _appRegistrar, _clientKeyToolkit, AppCallLimit);

            // passing them back to the view
            ViewBag.clientkeys  = clientkeys;
            ViewBag.clientExist = true;

            //
            return(View(model));
        }