示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var ctx = new EF.RepositoryContext("LogoDB"))
            {
                List <object> suggestions = new List <object>();

                foreach (var suggestion in ctx.Suggestions.Include("Channels").Include("Aliases").Include("Aliases.Channel").Include("Logos").Include("Logos.Channels").Include("User").OrderByDescending(s => s.LastModified))
                {
                    EF.Suggestion.SuggestionType suggestWhat;
                    EF.Channel channel = suggestion.GetSuggestedChannel(out suggestWhat);

                    string channelName = string.Format("{0} ({1})", channel.Name, channel.Type);

                    suggestions.Add(new
                    {
                        Id          = suggestion.Id,
                        Creation    = suggestion.Created.ToString("dd.MM.yyyy hh:mm"),
                        Type        = string.Format("New {0}", suggestWhat),
                        Channel     = channelName,
                        UserName    = suggestion.User != null ? suggestion.User.Login : "",
                        Region      = channel.RegionCode,
                        Aliases     = string.Join(", ", suggestion.Aliases.Select(a => a.Name)),
                        Description = channel.Description,
                        Logo        = suggestion.Logos.FirstOrDefault()
                    });
                }

                gvSuggestions.DataSource = suggestions;
                gvSuggestions.DataBind();
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (var ctx = new EF.RepositoryContext("LogoDB"))
                {
                    var suggestion = GetSuggestion(ctx);
                    if (suggestion != null)
                    {
                        EF.Suggestion.SuggestionType suggestWhat;
                        EF.Channel channel = suggestion.GetSuggestedChannel(out suggestWhat);

                        lblSuggestionDate.Text     = suggestion.Created.ToString("dd.MM.yyyy hh:mm");
                        lblSuggestWhat.Text        = string.Format("Suggestion for a new {0}", suggestWhat);
                        lblChannelName.Text        = string.Format("{0} ({1})", channel.Name, channel.Type);
                        linkChannel.NavigateUrl    = channel.Website;
                        linkChannel.Text           = channel.Website;
                        linkChannel.Visible        = !string.IsNullOrEmpty(channel.Website);
                        lblChannelRegion.Text      = channel.RegionCode;
                        lblChannelDescription.Text = channel.Description;

                        var logoNew = suggestion.Logos.FirstOrDefault();
                        if (logoNew != null)
                        {
                            imgChannelLogoNew.Visible     = true;
                            imgChannelLogoNew.ImageUrl    = string.Format("/Logos/{0}.png", logoNew.Id);
                            imgChannelLogoNew.NavigateUrl = string.Format("/Logos/{0}.png", logoNew.Id);
                            lblLogoMetadataNew.Text       = string.Format("{0}x{1}, {2:F1}KB", logoNew.Width, logoNew.Height, logoNew.SizeInBytes / 1024.0);
                            lblLogoMetadataNew.Visible    = true;
                            lblNewLogo.Visible            = true;
                        }

                        var logoOld = channel.Logos.FirstOrDefault(l => l.Suggestion == null);
                        if (logoOld != null)
                        {
                            imgChannelLogoOld.Visible     = true;
                            imgChannelLogoOld.ImageUrl    = string.Format("/Logos/{0}.png", logoOld.Id);
                            imgChannelLogoOld.NavigateUrl = string.Format("/Logos/{0}.png", logoOld.Id);
                            lblLogoMetadataOld.Text       = string.Format("{0}x{1}, {2:F1}KB", logoOld.Width, logoOld.Height, logoOld.SizeInBytes / 1024.0);
                            lblLogoMetadataOld.Visible    = true;
                            if (logoNew != null)
                            {
                                lblOldLogo.Visible = true;
                            }
                        }

                        string oldAliases = string.Join(", ", channel.Aliases.Where(a => a.Suggestion == null).Select(a => a.Name));
                        string newAliases = string.Join(", ", channel.Aliases.Where(a => a.Suggestion == suggestion).Select(a => a.Name));
                        lblChannelOldAliases.Text    = oldAliases;
                        lblChannelNewAliases.Text    = newAliases;
                        lblChannelOldAliases.Visible = oldAliases != "";
                        lblChannelNewAliases.Visible = newAliases != "";

                        gvMessages.DataSource = suggestion.Messages;
                        gvMessages.DataBind();
                    }
                }
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var canApproveOrDecline = Roles.IsUserInRole(RoleProvider.Roles.Administrator.ToString()) || Roles.IsUserInRole(RoleProvider.Roles.Maintainer.ToString());

            btnApprove.Visible = canApproveOrDecline;
            btnDecline.Visible = canApproveOrDecline;

            if (!IsPostBack)
            {
                using (var ctx = new EF.RepositoryContext("LogoDB"))
                {
                    var suggestion = GetSuggestion(ctx);
                    if (suggestion != null)
                    {
                        EF.Channel channel = suggestion.GetSuggestedChannel(out EF.Suggestion.SuggestionType? suggestWhat);

                        lblSuggestionDate.Text     = suggestion.Created.ToString("dd.MM.yyyy hh:mm");
                        lblAuthor.Text             = suggestion.User != null ? suggestion.User.Login : "";
                        lblSuggestWhat.Text        = suggestWhat != null ? $"Suggestion for a new {suggestWhat}" : "Invalid Suggestion";
                        lblChannelName.Text        = channel != null ? $"{channel.Name} ({channel.Type})" : "";
                        linkChannel.NavigateUrl    = channel?.Website;
                        linkChannel.Text           = channel?.Website;
                        linkChannel.Visible        = !string.IsNullOrEmpty(channel?.Website);
                        lblChannelRegion.Text      = channel?.RegionCode;
                        lblChannelDescription.Text = channel?.Description;

                        var logoNew = suggestion.Logos.FirstOrDefault();
                        if (logoNew != null)
                        {
                            imgChannelLogoNew.Visible     = true;
                            imgChannelLogoNew.ImageUrl    = string.Format("/Logos/{0}.png", logoNew.Id);
                            imgChannelLogoNew.NavigateUrl = string.Format("/Logos/{0}.png", logoNew.Id);
                            lblLogoMetadataNew.Text       = string.Format("{0}x{1}, {2:F1}KB", logoNew.Width, logoNew.Height, logoNew.SizeInBytes / 1024.0);
                            lblLogoMetadataNew.Visible    = true;
                            lblNewLogo.Visible            = true;
                        }

                        if (channel != null)
                        {
                            var logoOld = channel.Logos.FirstOrDefault(l => l.Suggestion == null);
                            if (logoOld != null)
                            {
                                imgChannelLogoOld.Visible     = true;
                                imgChannelLogoOld.ImageUrl    = string.Format("/Logos/{0}.png", logoOld.Id);
                                imgChannelLogoOld.NavigateUrl = string.Format("/Logos/{0}.png", logoOld.Id);
                                lblLogoMetadataOld.Text       = string.Format("{0}x{1}, {2:F1}KB", logoOld.Width, logoOld.Height, logoOld.SizeInBytes / 1024.0);
                                lblLogoMetadataOld.Visible    = true;
                                if (logoNew != null)
                                {
                                    lblOldLogo.Visible = true;
                                }
                            }

                            string oldAliases = string.Join(", ", channel.Aliases.Where(a => a.Suggestion == null).Select(a => a.Name));
                            string newAliases = string.Join(", ", channel.Aliases.Where(a => a.Suggestion == suggestion).Select(a => a.Name));
                            lblChannelOldAliases.Text    = oldAliases;
                            lblChannelNewAliases.Text    = newAliases;
                            lblChannelOldAliases.Visible = oldAliases != "";
                            lblChannelNewAliases.Visible = newAliases != "";
                        }

                        gvMessages.DataSource = suggestion.Messages;
                        gvMessages.DataBind();
                    }
                }
            }
        }