示例#1
0
        // GET: user
        public async Task <IActionResult> Index(string username, string status = null, string uid = null)
        {
            var model = new UserModelView();

            model.ActiveIndex = 0;

            if (!InitProfile(model, username))
            {
                return(Redirect(Config.GetUrl() + "signin?ReturnUrl=" + Config.GetUrl(username)));
            }

            // fetch profile user information
            var query = new MemberEntity()
            {
                ispublic = true,
                loadall  = true
            };

            if (Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption == 0)
            {
                query.username = model.UserName;
            }
            else
            {
                query.userid = model.UserName;
            }

            var userInfo = await UserProfileBLL.LoadItems(_context, query);

            if (userInfo.Count > 0)
            {
                // increment user views
                int _views = userInfo[0].views + 1;
                UserBLL.Update_Field_Id(_context, userInfo[0].Id, "views", _views);

                model.user = userInfo[0];

                model.Nav = new NavModelView()
                {
                    username    = model.user.Id,
                    ActiveIndex = 100
                };

                model.UserInfo = prepare_user_info(model);

                model.FullName = UserUrlConfig.PrepareUserName(model.user, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);

                ViewBag.title       = model.FullName + "'s " + SiteConfig.generalLocalizer["_profile"].Value;
                ViewBag.description = ViewBag.title + ", info: " + model.UserInfo + ", date joined: " + model.user.created_at;
            }
            else
            {
                model.UserExist = false;
            }
            return(View(model));
        }
示例#2
0
        // GET: user
        public async Task <IActionResult> Index(string username, string status = null, string uid = null)
        {
            var model = new UserModelView();

            model.ActiveIndex = 0;

            if (!InitProfile(model, username))
            {
                return(Redirect(Config.GetUrl() + "signin?ReturnUrl=" + Config.GetUrl(username)));
            }

            // fetch profile user information
            var query = new MemberEntity()
            {
                ispublic = true,
                loadall  = true
            };

            if (Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption == 0)
            {
                query.username = model.UserName;
            }
            else
            {
                query.userid = model.UserName;
            }

            var userInfo = await UserProfileBLL.LoadItems(_context, query);

            if (userInfo.Count > 0)
            {
                // increment user views
                int _views = userInfo[0].views + 1;
                UserBLL.Update_Field_Id(_context, userInfo[0].Id, "views", _views);

                model.user = userInfo[0];

                model.Nav = new NavModelView()
                {
                    username       = model.user.Id,
                    ActiveIndex    = 100,
                    ShowForumPosts = getValue(model.user.stats.stat_forum_topics),
                    CountTopics    = model.user.stats.stat_forum_topics
                };

                model.UserInfo = prepare_user_info(model);

                model.FullName = UserUrlConfig.PrepareUserName(model.user, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);


                model.forumtopics = new ForumTopicsListViewModel()
                {
                    BrowseText   = SiteConfig.generalLocalizer["_see_all"].Value,
                    HeadingTitle = model.FullName + " " + SiteConfig.generalLocalizer["_forum_topics"].Value,
                    ListObject   = new ListItems()
                    {
                        showViews = true,
                        showDate  = true
                    },
                    BrowseUrl    = Config.GetUrl("user/forums/" + model.UserName),
                    QueryOptions = new Jugnoon.Forums.ForumTopicEntity()
                    {
                        userid   = model.user.Id,
                        order    = "topic.created_at desc",
                        ispublic = true,
                        pagesize = 6
                    }
                };

                ViewBag.title       = model.FullName + "'s " + SiteConfig.generalLocalizer["_profile"].Value;
                ViewBag.description = ViewBag.title + ", info: " + model.UserInfo + ", date joined: " + model.user.created_at;
            }
            else
            {
                model.UserExist = false;
            }
            return(View(model));
        }
示例#3
0
        public async Task <IActionResult> topics(string username, int?pagenumber)
        {
            if (pagenumber == null)
            {
                pagenumber = 1;
            }

            var model = new UserModelView();

            model.ActiveIndex = 8;

            if (!InitProfile(model, username))
            {
                return(Redirect(Config.GetUrl() + "signin?ReturnUrl=" + Config.GetUrl(username)));
            }

            // fetch profile user information
            var query = new MemberEntity()
            {
                ispublic = true,
                loadall  = true
            };

            if (Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption == 0)
            {
                query.username = model.UserName;
            }
            else
            {
                query.userid = model.UserName;
            }


            var userInfo = await UserProfileBLL.LoadItems(_context, query);

            if (userInfo.Count > 0)
            {
                model.user = userInfo[0];

                model.UserInfo = prepare_user_info(model);

                model.FullName = UserUrlConfig.PrepareUserName(model.user, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);

                model.Nav = new NavModelView()
                {
                    username       = model.UserName,
                    ActiveIndex    = 100,
                    ShowForumPosts = getValue(model.user.stats.stat_forum_topics),
                    CountTopics    = model.user.stats.stat_forum_topics,
                };
                var _title = model.FullName + "'s " + SiteConfig.generalLocalizer["_posted_topics"] + " (" + userInfo[0].stats.stat_forum_topics + ")"; //
                /* List Settings */
                model.forumtopics = new ForumTopicsListViewModel()
                {
                    isListStatus = false,
                    QueryOptions = new Jugnoon.Forums.ForumTopicEntity()
                    {
                        pagenumber = (int)pagenumber,
                        userid     = model.user.Id,
                        term       = "",
                        iscache    = false,
                        ispublic   = true,
                        pagesize   = 20,
                        order      = "topic.created_at desc",
                    },
                    ListObject        = new ListItems(),
                    HeadingTitle      = _title,
                    DefaultUrl        = Config.GetUrl("user/topics/" + model.UserName),
                    PaginationUrl     = Config.GetUrl("user/topics/" + model.UserName + "/[p]/"),
                    NoRecordFoundText = SiteConfig.generalLocalizer["_no_records"].Value,
                };
                ViewBag.title = _title;
            }
            else
            {
                model.UserExist = false;
            }
            return(View(model));
        }
示例#4
0
        public async Task <IActionResult> profile(string username)
        {
            var model = new UserModelView();

            model.ActiveIndex = 10; // profile section

            if (!InitProfile(model, username))
            {
                return(Redirect(Config.GetUrl() + "signin?ReturnUrl=" + Config.GetUrl(username)));
            }

            if (!InitProfile(model, username))
            {
                return(Redirect(Config.GetUrl() + "signin?ReturnUrl=" + Config.GetUrl(username)));
            }

            // fetch profile user information
            var query = new MemberEntity()
            {
                ispublic = true,
                loadall  = true
            };

            if (Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption == 0)
            {
                query.username = model.UserName;
            }
            else
            {
                query.userid = model.UserName;
            }


            var userInfo = await UserProfileBLL.LoadItems(_context, query);

            if (userInfo.Count > 0)
            {
                model.user = userInfo[0];
                // load dynamic attributes
                model.attr_values = await AttrValueBLL.LoadItems(_context, new AttrValueEntity()
                {
                    userid    = model.user.Id,
                    attr_type = Attr_Type.UserProfile,
                    order     = "priority desc",
                    nofilter  = false
                });


                model.UserInfo = prepare_user_info(model);

                model.FullName = UserUrlConfig.PrepareUserName(model.user, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);

                model.Nav = new NavModelView()
                {
                    username    = model.UserName,
                    ActiveIndex = 100,
                };
            }
            else
            {
                model.UserExist = false;
            }


            ViewBag.title = model.FullName + "'s " + SiteConfig.generalLocalizer["_profile_detail"].Value;

            return(View(model));
        }
示例#5
0
        public async Task <ActionResult> getinfo()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <MemberEntity>(json);

            if (data.id == "")
            {
                var _post = new ApplicationUser();
                _post.options = await AttrTemplatesSectionsBLL.LoadItems(_context, new AttrTemplateSectionEntity()
                {
                    templateid = 0, // if you want to manage multiple templates for dynamic attributes use it here
                    attr_type  = Attr_Type.UserProfile,
                    order      = "priority desc",
                    iscache    = true
                });

                foreach (var option in _post.options)
                {
                    option.attributes = await AttrAttributeBLL.LoadItems(_context, new AttrAttributeEntity()
                    {
                        sectionid = option.id,
                        order     = "priority desc",
                        iscache   = true,
                        attr_type = (byte)Attr_Type.UserProfile
                    });
                }
                return(Ok(new { status = "success", post = _post }));
            }
            else
            {
                var _posts = await UserProfileBLL.LoadItems(_context, data);

                if (_posts.Count == 0)
                {
                    return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_no_records"].Value }));
                }

                // Raw Attributes
                _posts[0].options = await AttrTemplatesSectionsBLL.LoadItems(_context, new AttrTemplateSectionEntity()
                {
                    templateid = 0, // if you want to manage multiple templates for dynamic attributes use it here
                    order      = "priority desc",
                    attr_type  = Attr_Type.UserProfile,
                    iscache    = true
                });

                foreach (var option in _posts[0].options)
                {
                    option.attributes = await AttrAttributeBLL.LoadItems(_context, new AttrAttributeEntity()
                    {
                        sectionid = option.id,
                        order     = "priority desc",
                        iscache   = true,
                        attr_type = (byte)Attr_Type.UserProfile
                    });
                }

                _posts[0].attr_values = await AttrValueBLL.LoadItems(_context, new AttrValueEntity()
                {
                    userid    = _posts[0].Id,
                    attr_type = Attr_Type.UserProfile,
                    nofilter  = false
                });

                _posts[0].img_url = UserUrlConfig.ProfilePhoto(_posts[0].UserName, _posts[0].picturename, 0); // default set
                _posts[0].url     = UserUrlConfig.ProfileUrl(_posts[0], Configs.RegistrationSettings.uniqueFieldOption);
                _posts[0].customize_register_date = UtilityBLL.CustomizeDate((DateTime)_posts[0].created_at, DateTime.Now);
                if (_posts[0].last_login != null)
                {
                    _posts[0].customize_last_login = UtilityBLL.CustomizeDate((DateTime)_posts[0].last_login, DateTime.Now);
                }
                return(Ok(new { status = "ok", post = _posts[0] }));
            }
        }
示例#6
0
        public async Task <ActionResult> getUserAuth()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <MemberEntity>(json);

            data.nofilter   = false;
            data.issummary  = false;
            data.isdropdown = false;

            if (data.id == "")
            {
                return(Ok(new { status = "error", message = "User Information Mising" }));
            }

            // check user authorize
            //if (_signInManager.IsSignedIn(User))
            //{
            //var info = await SiteConfig.userManager.GetUserAsync(User);
            //if (info.Id == data.id)
            //{
            var _posts = await UserProfileBLL.LoadItems(_context, data);

            if (_posts.Count == 0)
            {
                return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_no_records"].Value }));
            }
            _posts[0].img_url = UserUrlConfig.ProfilePhoto(_posts[0].UserName, _posts[0].picturename, 0); // default set
            _posts[0].url     = UserUrlConfig.ProfileUrl(_posts[0], Configs.RegistrationSettings.uniqueFieldOption);
            _posts[0].customize_register_date = UtilityBLL.CustomizeDate((DateTime)_posts[0].created_at, DateTime.Now);


            if (_posts[0].last_login != null)
            {
                _posts[0].customize_last_login = UtilityBLL.CustomizeDate((DateTime)_posts[0].last_login, DateTime.Now);
            }
            var _roles = new List <JGN_Roles>();

            if (data.isadmin)
            {
                if (_posts[0].roleid > 0)
                {
                    _roles = await RoleBLL.LoadItems(_context, new RoleEntity()
                    {
                        id = _posts[0].roleid,
                    });

                    if (_roles.Count > 0)
                    {
                        foreach (var post in _posts)
                        {
                            _roles[0].permissions = await RolePermission.LoadItems(_context, new RoleDPermissionEntity()
                            {
                                roleid     = _roles[0].id,
                                pagesize   = 5000,
                                pagenumber = 1
                            });
                        }
                    }
                }
            }

            var authClaims = new[]
            {
                new Claim(JwtRegisteredClaimNames.Sub, _posts[0].UserName),
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
            };

            var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configs.GeneralSettings.jwt_private_key));


            var token = new JwtSecurityToken(
                issuer: SiteConfiguration.URL,
                audience: SiteConfiguration.URL,
                expires: DateTime.Now.AddHours(10),
                claims: authClaims,
                signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256)
                );

            return(Ok(new
            {
                status = "ok",
                token = new JwtSecurityTokenHandler().WriteToken(token),
                expiration = token.ValidTo,
                post = _posts[0],
                role = _roles
            }));
            //}
            //else
            //{
            //    return Ok(new { status = "error", message = "Bad Request" });
            //}
            //}
            //else
            //{
            //    return Ok(new { status = "error", message = "Authentication Failed" });
            // }
        }
        // GET: user
        public async Task <IActionResult> Index(string username, string status = null, string uid = null)
        {
            var model = new UserModelView();

            model.ActiveIndex = 0;

            if (!InitProfile(model, username))
            {
                return(Redirect(Config.GetUrl() + "signin?ReturnUrl=" + Config.GetUrl(username)));
            }

            // fetch profile user information
            var query = new MemberEntity()
            {
                ispublic = true,
                loadall  = true
            };

            if (Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption == 0)
            {
                query.username = model.UserName;
            }
            else
            {
                query.userid = model.UserName;
            }

            var userInfo = await UserProfileBLL.LoadItems(_context, query);

            if (userInfo.Count > 0)
            {
                // increment user views
                int _views = userInfo[0].views + 1;
                UserBLL.Update_Field_Id(_context, userInfo[0].Id, "views", _views);

                model.user = userInfo[0];

                model.Nav = new NavModelView()
                {
                    username       = model.user.Id,
                    ActiveIndex    = 100,
                    ShowVideos     = getValue(model.user.stats.stat_videos),
                    CountVideos    = model.user.stats.stat_videos,
                    CountAudio     = model.user.stats.stat_audio,
                    ShowForumPosts = getValue(model.user.stats.stat_forum_topics),
                    CountTopics    = model.user.stats.stat_forum_topics,
                    CountPhotos    = model.user.stats.stat_photos,
                    Showqa         = getValue(model.user.stats.stat_qa),
                    Countqa        = model.user.stats.stat_qa
                };

                model.UserInfo = prepare_user_info(model);

                model.FullName = UserUrlConfig.PrepareUserName(model.user, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);

                if (Jugnoon.Settings.Configs.FeatureSettings.enable_videos)
                {
                    model.videos = new VideoListViewModel()
                    {
                        BrowseText   = SiteConfig.generalLocalizer["_see_all"].Value,
                        HeadingTitle = model.FullName + " " + SiteConfig.videoLocalizer["videos"].Value,
                        ListObject   = new ListItems()
                        {
                            ListType    = ListType.Grid,
                            ColWidth    = "col-md-4",
                            TitleLength = 40,
                            showViews   = true,
                            showRating  = true,
                            showDate    = true
                        },
                        BrowseUrl    = Config.GetUrl("user/videos/" + model.UserName),
                        QueryOptions = new VideoEntity()
                        {
                            userid     = model.user.Id,
                            order      = "video.created_at desc",
                            ispublic   = true,
                            isfeatured = FeaturedTypes.All,
                            pagesize   = 6,
                            type       = 0 // 0: videos, 1: audio
                        }
                    };
                }

                ViewBag.title       = model.FullName + "'s " + SiteConfig.generalLocalizer["_profile"].Value;
                ViewBag.description = ViewBag.title + ", info: " + model.UserInfo + ", date joined: " + model.user.created_at;
            }
            else
            {
                model.UserExist = false;
            }
            return(View(model));
        }
        public async Task <IActionResult> videos(string username, int?pagenumber)
        {
            if (pagenumber == null)
            {
                pagenumber = 1;
            }

            var model = new UserModelView();

            model.ActiveIndex = 8;

            if (!InitProfile(model, username))
            {
                return(Redirect(Config.GetUrl() + "signin?ReturnUrl=" + Config.GetUrl(username)));
            }

            // fetch profile user information
            var query = new MemberEntity()
            {
                ispublic = true,
                loadall  = true
            };

            if (Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption == 0)
            {
                query.username = model.UserName;
            }
            else
            {
                query.userid = model.UserName;
            }


            var userInfo = await UserProfileBLL.LoadItems(_context, query);

            if (userInfo.Count > 0)
            {
                model.user = userInfo[0];

                model.UserInfo = prepare_user_info(model);

                model.FullName = UserUrlConfig.PrepareUserName(model.user, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);

                var _title = model.FullName + "'s " + SiteConfig.videoLocalizer["_uploaded_videos"] + " (" + userInfo[0].stats.stat_videos + ")";

                model.Nav = new NavModelView()
                {
                    username       = model.UserName,
                    ActiveIndex    = 100,
                    ShowVideos     = getValue(model.user.stats.stat_videos),
                    CountVideos    = model.user.stats.stat_videos,
                    CountAudio     = model.user.stats.stat_audio,
                    ShowForumPosts = getValue(model.user.stats.stat_forum_topics),
                    CountTopics    = model.user.stats.stat_forum_topics,
                    CountPhotos    = model.user.stats.stat_photos,
                    Showqa         = getValue(model.user.stats.stat_qa),
                    Countqa        = model.user.stats.stat_qa
                };

                /* List Settings */
                model.videos = new VideoListViewModel()
                {
                    isListStatus = false,
                    QueryOptions = new VideoEntity()
                    {
                        type       = 0, // 0: videos, 1: audio
                        pagenumber = (int)pagenumber,
                        userid     = model.user.Id,
                        iscache    = false,
                        ispublic   = true,
                        isfeatured = FeaturedTypes.All,
                        pagesize   = Jugnoon.Settings.Configs.GeneralSettings.pagesize,
                        order      = "video.created_at desc",
                    },
                    ListObject = new ListItems()
                    {
                        ColWidth    = "col-md-4",
                        ListType    = ListType.Grid,
                        TitleLength = 40,
                        showViews   = true,
                        showRating  = true,
                        showDate    = true
                    },
                    HeadingTitle = _title,

                    DefaultUrl        = Config.GetUrl("user/videos/" + model.UserName),
                    PaginationUrl     = Config.GetUrl("user/videos/" + model.UserName + "/[p]/"),
                    NoRecordFoundText = SiteConfig.generalLocalizer["_no_records"].Value,
                };
                model.videos.TotalRecords = await VideoBLL.Count(_context, model.videos.QueryOptions);

                if (model.videos.TotalRecords > 0)
                {
                    model.videos.DataList = await VideoBLL.LoadItems(_context, model.videos.QueryOptions);
                }

                ViewBag.title = _title;
            }
            else
            {
                model.UserExist = false;
            }
            return(View(model));
        }