Esempio n. 1
0
        public async Task <string> RenderAsync(string model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            YTagBuilder tag = new YTagBuilder("span");

            FieldSetup(tag, FieldType.Anonymous);

            ModuleAction actionDisplay = null;
            ModuleAction actionLoginAs = null;

            using (UserDefinitionDataProvider userDefDP = new UserDefinitionDataProvider()) {
                UserDefinition user     = null;
                string         userName = "";
                if (!string.IsNullOrWhiteSpace(model))
                {
                    user = await userDefDP.GetItemByEmailAsync(model);

                    if (user == null)
                    {
                        userName = model;
                    }
                    else
                    {
                        userName = user.Email;
                        UsersDisplayModule modDisp = new UsersDisplayModule();
                        actionDisplay = modDisp.GetAction_Display(null, user.UserName);
                        LoginModule modLogin = (LoginModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(LoginModule));

                        actionLoginAs = await modLogin.GetAction_LoginAsAsync(user.UserId, user.UserName);
                    }
                }
                else
                {
                    userName = __ResStr("noEmail", "(not specified)");
                }
                tag.SetInnerText(userName);
            }
            hb.Append(tag.ToString(YTagRenderMode.Normal));
            if (actionDisplay != null)
            {
                hb.Append(await actionDisplay.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }
            if (actionLoginAs != null)
            {
                hb.Append(await actionLoginAs.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }
            return(hb.ToString());
        }