#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.225
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace System.Web.WebPages.Administration.PackageManager
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Web;
    using System.Web.Helpers;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.WebPages;
    using System.Web.WebPages.Html;
    using System.Globalization;
    
    [System.Web.WebPages.PageVirtualPathAttribute("~/packages/PackageSources.cshtml")]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorSingleFileGenerator", "1.0.0.0")]
    public class packages_PackageSources_cshtml : System.Web.WebPages.WebPage
    {
#line hidden

                    // Resolve package relative syntax
                    // Also, if it comes from a static embedded resource, change the path accordingly
                    public override string Href(string virtualPath, params object[] pathParts) {
                        virtualPath = ApplicationPart.ProcessVirtualPath(GetType().Assembly, VirtualPath, virtualPath);
                        return base.Href(virtualPath, pathParts);
                    }
        public packages_PackageSources_cshtml()
        {
        }
        protected System.Web.HttpApplication ApplicationInstance
        {
            get
            {
                return ((System.Web.HttpApplication)(Context.ApplicationInstance));
            }
        }
        public override void Execute()
        {


WriteLiteral("\r\n\r\n");



  
    // Setup layout
    var currentPage = Href(PageUtils.GetPageVirtualPath("PackageSources"));
    PageData["BreadCrumbs"].Add(Tuple.Create(PackageManagerResources.ManageSourcesTitle, currentPage));
    Page.Desc = PackageManagerResources.ManageSourcesDesc;
    Page.SectionTitle = PackageManagerResources.ManageSourcesTitle;

    if (IsPost) {
        AntiForgery.Validate();
        var action = Request.Form["action"];
        var sourceUrl = Request.Form["sourceUrl"];
        var sourceName = Request.Form["sourceName"];
        try { 
            if (action.Equals(PackageManagerResources.AddPackageSourceLabel, StringComparison.OrdinalIgnoreCase)) {

                ModelState.SetModelValue("sourceName", sourceName);
                ModelState.SetModelValue("sourceUrl", sourceUrl);

                Uri url;
                if (!Uri.TryCreate(sourceUrl, UriKind.Absolute, out url)) {
                    ModelState.AddError("sourceUrl", PackageManagerResources.Validation_InvalidPackageSourceUrl);
                } else if (!PackageManagerModule.AddPackageSource(source: sourceUrl, name: sourceName)) {
                    ModelState.AddError("sourceName", PackageManagerResources.Validation_PackageSourceAlreadyExists);
                } else {
                    // The feed was successfully added. Clear the model state.
                    ModelState.Clear();
                }
            }
            else if (action.Equals(PackageManagerResources.DeleteLabel, StringComparison.OrdinalIgnoreCase)) {
                PackageManagerModule.RemovePackageSource(sourceName);
            }
            else if (action.Equals(PackageManagerResources.RestoreDefaultSources, StringComparison.OrdinalIgnoreCase)) {
                foreach(var packageSource in PackageManagerModule.DefaultSources) {
                    PackageManagerModule.AddPackageSource(packageSource);
                }
            }
        } catch (UnauthorizedAccessException) {

WriteLiteral("            <div class=\"message error\">\r\n                ");


           Write(String.Format(CultureInfo.CurrentCulture, PackageManagerResources.PackageSourceFileInstructions, PackageManagerModule.PackageSourceFilePath));

WriteLiteral("\r\n            </div>\r\n");


        } 
    }

    var numSources = PackageManagerModule.PackageSources.Count();


WriteLiteral("\r\n");


Write(Html.ValidationSummary(excludeFieldErrors: true));

WriteLiteral("\r\n\r\n<table id=\"feeds\">\r\n<thead>\r\n    <tr>\r\n        <th scope=\"col\">");


                   Write(PackageManagerResources.SourceNameLabel);

WriteLiteral("</th>\r\n        <th scope=\"col\">");


                   Write(PackageManagerResources.SourceUrlLabel);

WriteLiteral("</th>\r\n        <th></th>\r\n    </tr>\r\n</thead>\r\n<tbody>     \r\n");


     foreach(var source in PackageManagerModule.PackageSources) {

WriteLiteral("    <tr>\r\n        <td>");


       Write(source.Name);

WriteLiteral("</td>\r\n        <td><a href=\"");


                Write(source.Source);

WriteLiteral("\">");


                                Write(source.Source);

WriteLiteral("</a></td>\r\n        <td>\r\n");


             if(numSources > 1) {

WriteLiteral("                <form method=\"post\" action=\"\">\r\n                    <input type=\"" +
"hidden\" name=\"sourceName\" value=\"");


                                                             Write(source.Name);

WriteLiteral("\" />\r\n                    <input type=\"submit\" name=\"action\" value=\"");


                                                         Write(PackageManagerResources.DeleteLabel);

WriteLiteral("\" />\r\n                    ");


               Write(AntiForgery.GetHtml());

WriteLiteral("\r\n                </form>\r\n");


            }

WriteLiteral("        </td>\r\n    </tr>\r\n");


    }

WriteLiteral("</tbody>\r\n</table>\r\n<br />\r\n<form method=\"post\" action=\"\">\r\n");


Write(AntiForgery.GetHtml());

WriteLiteral("\r\n<fieldset>\r\n    <legend>");


       Write(PackageManagerResources.AddPackageSourceLabel);

WriteLiteral("</legend>\r\n    <ol>\r\n        <li>\r\n            <label for=\"feedName\">");


                             Write(PackageManagerResources.SourceNameLabel);

WriteLiteral(":</label>\r\n            ");


       Write(Html.TextBox("sourceName"));

WriteLiteral(" ");


                                   Write(Html.ValidationMessage("sourceName"));

WriteLiteral("\r\n        </li>\r\n        <li>\r\n            <label for=\"feedUrl\">");


                            Write(PackageManagerResources.SourceUrlLabel);

WriteLiteral(":</label>\r\n            ");


       Write(Html.TextBox("sourceUrl"));

WriteLiteral(" ");


                                  Write(Html.ValidationMessage("sourceUrl"));

WriteLiteral("\r\n        </li>\r\n    </ol>\r\n    <p class=\"form-actions\">\r\n        \r\n    <input ty" +
"pe=\"submit\" name=\"action\" class=\"long-input\" value=\"");


                                                            Write(PackageManagerResources.AddPackageSourceLabel);

WriteLiteral("\" />\r\n    </p>\r\n</fieldset>\r\n</form>\r\n\r\n");


  
    if (PackageManagerModule.DefaultSources.Intersect(PackageManagerModule.PackageSources).Count() != PackageManagerModule.DefaultSources.Count()) { 

WriteLiteral("    <p>\r\n        <form method=\"post\" action=\"\">\r\n            ");


       Write(AntiForgery.GetHtml());

WriteLiteral("\r\n            <fieldset class=\"no-border\">  \r\n                <input type=\"submit" +
"\" name=\"action\" class=\"long-input\"  value=\"");


                                                                         Write(PackageManagerResources.RestoreDefaultSources);

WriteLiteral("\" />\r\n            </fieldset>\r\n        </form>\r\n    </p>\r\n");


    }



        }
    }
}
#pragma warning restore 1591
