示例#1
0
        public IActionResult Index()
        {
            ViewData["Count"] = 1;
            if (ViewData.Keys.Contains("Count"))
            {
                ViewData["Count"] = Convert.ToInt32(ViewData["Count"]) + 1;
            }
            else
            {
                ViewData["Count"] = 1;
            }

            if (ViewBag.Count != null)
            {
                ViewBag.Count = ViewBag.Count++;
            }
            else
            {
                ViewBag.Count = 1;
            }

            if (TempData.Keys.Contains("Count"))
            {
                TempData["Count"] = Convert.ToInt32(TempData["Count"]) + 1;
            }
            else
            {
                TempData["Count"] = 1;
            }

            if (HttpContext.Session.Keys.Contains("Count"))
            {
                HttpContext.Session.Set <int>("Count", HttpContext.Session.Get <int>("Count") + 1);
            }
            else
            {
                HttpContext.Session.Set <int>("Count", 1);
            }

            if (_applicationData.Keys.Contains("Count"))
            {
                _applicationData.Set <int>("Count", _applicationData.Get <int>("Count") + 1);
            }
            else
            {
                _applicationData.Set <int>("Count", 1);
            }

            return(View());
        }
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
            BeginContext(107, 2, true);
            WriteLiteral("\r\n");
            EndContext();
#line 7 "D:\GitHub\NetCoreIntermedio\01 - Componentes MVC Y aplicando seguridad al Website\Galaxy.MVC\Galaxy.MVC.Session\Views\Home\Index.cshtml"

            int sessionCount = HttpContextAccessor.HttpContext.Session.Get <int>("Count");
            int appDataCount = ApplicationData.Get <int>("Count");

#line default
#line hidden
            BeginContext(349, 332, true);
            WriteLiteral(@"
<div class=""row"">
    <div class=""col-sm-4"">
        <div class=""card shadow p-3 mb-5 bg-white rounded"" style=""border-color:#7030a0"">
            <div class=""card-body"">
                <h5 class=""card-title"" style=""color:#7030a0"">ViewData</h5>
                <p class=""card-text"">Contador :</p>
                <p><strong>");
            EndContext();
            BeginContext(682, 17, false);
#line 18 "D:\GitHub\NetCoreIntermedio\01 - Componentes MVC Y aplicando seguridad al Website\Galaxy.MVC\Galaxy.MVC.Session\Views\Home\Index.cshtml"
            Write(ViewData["Count"]);

#line default
#line hidden
            EndContext();
            BeginContext(699, 377, true);
            WriteLiteral(@"</strong></p>
            </div>
        </div>
    </div>
    <div class=""col-sm-4"">
        <div class=""card shadow p-3 mb-5 bg-white rounded"" style=""border-color:#1f4e79"">
            <div class=""card-body"">
                <h5 class=""card-title"" style=""color:#1f4e79"">ViewBag</h5>
                <p class=""card-text"">Contador :<br></p>
                <p><strong>");
            EndContext();
            BeginContext(1077, 13, false);
#line 27 "D:\GitHub\NetCoreIntermedio\01 - Componentes MVC Y aplicando seguridad al Website\Galaxy.MVC\Galaxy.MVC.Session\Views\Home\Index.cshtml"
            Write(ViewBag.Count);

#line default
#line hidden
            EndContext();
            BeginContext(1090, 374, true);
            WriteLiteral(@"</strong></p>
            </div>
        </div>
    </div>
    <div class=""col-sm-4"">
        <div class=""card shadow p-3 mb-5 bg-white rounded"" style=""border-color:#00b050"">
            <div class=""card-body"">
                <h5 class=""card-title"" style=""color:#00b050"">TempData</h5>
                <p class=""card-text"">Contador :</p>
                <p><strong>");
            EndContext();
            BeginContext(1465, 17, false);
#line 36 "D:\GitHub\NetCoreIntermedio\01 - Componentes MVC Y aplicando seguridad al Website\Galaxy.MVC\Galaxy.MVC.Session\Views\Home\Index.cshtml"
            Write(TempData["Count"]);

#line default
#line hidden
            EndContext();
            BeginContext(1482, 373, true);
            WriteLiteral(@"</strong></p>
            </div>
        </div>
    </div>
    <div class=""col-sm-4"">
        <div class=""card shadow p-3 mb-5 bg-white rounded"" style=""border-color:#c00000"">
            <div class=""card-body"">
                <h5 class=""card-title"" style=""color:#c00000"">Session</h5>
                <p class=""card-text"">Contador :</p>
                <p><strong>");
            EndContext();
            BeginContext(1856, 12, false);
#line 45 "D:\GitHub\NetCoreIntermedio\01 - Componentes MVC Y aplicando seguridad al Website\Galaxy.MVC\Galaxy.MVC.Session\Views\Home\Index.cshtml"
            Write(sessionCount);

#line default
#line hidden
            EndContext();
            BeginContext(1868, 381, true);
            WriteLiteral(@"</strong></p>
            </div>
        </div>
    </div>
    <div class=""col-sm-4"">
        <div class=""card shadow p-3 mb-5 bg-white rounded"" style=""border-color:#2d9dbd"">
            <div class=""card-body"">
                <h5 class=""card-title"" style=""color:#2d9dbd"">ApplicationData</h5>
                <p class=""card-text"">Contador :</p>
                <p><strong>");
            EndContext();
            BeginContext(2250, 12, false);
#line 54 "D:\GitHub\NetCoreIntermedio\01 - Componentes MVC Y aplicando seguridad al Website\Galaxy.MVC\Galaxy.MVC.Session\Views\Home\Index.cshtml"
            Write(appDataCount);

#line default
#line hidden
            EndContext();
            BeginContext(2262, 81, true);
            WriteLiteral("</strong></p>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>\r\n\r\n\r\n\r\n\r\n\r\n");
            EndContext();
        }
示例#3
0
        public static async Task <bool> CreateOrEditNaughtyList(DiscordSocketClient client, string channelName, SocketUser userEdit = null)
        {
            channelName = channelName.Trim();
            if (string.IsNullOrWhiteSpace(channelName))
            {
                channelName = xs.Settings.GetWorkingChannel();
            }

            SocketTextChannel channel = FindChannel(client, channelName);

            if (channel == null)
            {
                return(false);
            }

            string          artMissing  = "";
            ApplicationData artHistory0 = GetAppDataFromHistory(0);

            if (artHistory0 != null)
            {
                artMissing = GetMissingArtToStr(artHistory0);
            }

            string          artMissingHistory1 = "";
            ApplicationData artHistory1        = GetAppDataFromHistory(1);

            if (artHistory1 != null)
            {
                artMissingHistory1 = GetMissingArtToStr(artHistory1);
            }

            string          artMissingHistory2 = "";
            ApplicationData artHistory2        = GetAppDataFromHistory(2);

            if (artHistory2 != null)
            {
                artMissingHistory2 = GetMissingArtToStr(artHistory2);
            }

            string naughtyList = "";

            if (!string.IsNullOrWhiteSpace(artMissing))
            {
                naughtyList += $"\n`{artHistory0.GetTheme()}` : {artMissing}";
            }
            if (!string.IsNullOrWhiteSpace(artMissingHistory1))
            {
                naughtyList += $"\n`{artHistory1.GetTheme()}` : {artMissingHistory1}";
            }
            if (!string.IsNullOrWhiteSpace(artMissingHistory2))
            {
                naughtyList += $"\n`{artHistory2.GetTheme()}` : {artMissingHistory2}";
            }

            var reply = Utils.EmbedMessage(client, $"**Naughty List**\nif you are on the list {string.Format(Properties.Resources.GLOBAL_CMDHELP, Config.CmdPrefix, $"reveal art <theme name>", "register the missing art for the listed themes:")}{naughtyList}", Utils.Emotion.negative);

            if (userEdit != null)
            {
                if (artHistory0.Get(userEdit.Id) == null && artHistory1.Get(userEdit.Id) == null && artHistory2.Get(userEdit.Id) == null)
                {
                    return(true);
                }

                var naughtyMsg = await FindChannelMessage(client, xs.Settings.GetNaughtyListMessageId());

                if (naughtyMsg == null)
                {
                    return(false);
                }

                var restMsg = naughtyMsg as Discord.Rest.RestUserMessage;
                if (restMsg == null)
                {
                    return(false);
                }

                if (string.IsNullOrWhiteSpace(naughtyList))
                {
                    await EditMessagePin(client, xs.Settings.GetNaughtyListMessageId(), false /*unpin*/);

                    await naughtyMsg.DeleteAsync();

                    xs.Settings.SetNaughtyListMessageId(0);
                }
                else
                {
                    await restMsg.ModifyAsync(x => x.Embed = reply);
                }
            }
            else if (!string.IsNullOrWhiteSpace(naughtyList))
            {
                await EditMessagePin(client, xs.Settings.GetNaughtyListMessageId(), false /*unpin*/);

                var naughtyMsg = await channel.SendMessageAsync(embed : reply);

                xs.Settings.SetNaughtyListMessageId(naughtyMsg.Id);

                await EditMessagePin(client, naughtyMsg.Id, true /*pin*/);
            }

            return(true);
        }