Пример #1
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));
        }
Пример #2
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] }));
            }
        }