#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;
    using NuGet;
    
    [System.Web.WebPages.PageVirtualPathAttribute("~/packages/Install.cshtml")]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorSingleFileGenerator", "0.6.0.0")]
    public class packages_Install_cshtml : System.Web.WebPages.WebPage
    {


                    // 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_Install_cshtml()
        {
        }
        protected System.Web.HttpApplication ApplicationInstance
        {
            get
            {
                return ((System.Web.HttpApplication)(Context.ApplicationInstance));
            }
        }
        public override void Execute()
        {


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





WriteLiteral("\r\n");


DefineSection("PackageHead", () => {

WriteLiteral(" \r\n    <script type=\"text/javascript\" src=\"");


                                   Write(Href("scripts/PackageAction.js"));

WriteLiteral("\"></script>\r\n    <noscript>");


         Write(PackageManagerResources.JavascriptRequired);

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


});

WriteLiteral("\r\n");


  
    // Read params from request
    var sourceName = Request["source"];
    var packageId = Request["package"];
    var version = Request["version"];

    var packageSource = PageUtils.GetPackageSource(sourceName);
    
    WebProjectManager projectManager;
    try {
        projectManager = new WebProjectManager(packageSource.Source, PackageManagerModule.SiteRoot);
    } catch (Exception exception) {

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


                              Write(exception.Message);

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


        return;
    }
    IPackage package = projectManager.SourceRepository.FindPackage(packageId, version != null ? SemanticVersion.Parse(version) : null);

    if (package == null) {
        ModelState.AddFormError(PackageManagerResources.BadRequest);
        
   Write(Html.ValidationSummary());

                                 
        return; 
    } 
    
    Page.SectionTitle = String.Format(CultureInfo.CurrentCulture, PackageManagerResources.InstallPackageDesc, package.GetDisplayName());

    var packagesHomeUrl = Href(PageUtils.GetPackagesHome(), Request.Url.Query);
    if (IsPost) {
        AntiForgery.Validate();
        try {
            projectManager.InstallPackage(package);   
        } catch (Exception exception) {
            ModelState.AddFormError(exception.Message);
        }
        
        if (ModelState.IsValid) {
            Response.Redirect(packagesHomeUrl + "&action-completed=Install");
        }
        else {
            
       Write(Html.ValidationSummary(String.Format(CultureInfo.CurrentCulture, PackageManagerResources.PackageInstallationError, package.GetDisplayName())));

                                                                                                                                                          
            return;
        }
    }


WriteLiteral("\r\n");


Write(RenderPage("_PackageDetails.cshtml", new Dictionary<string, object>{ {"Package", package} }));

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


  
    var licensePackages = projectManager.GetPackagesRequiringLicenseAcceptance(package);
    if (licensePackages.Any()) {

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



WriteLiteral("       <ul>\r\n");


             foreach(var licensePackage in licensePackages.Where(p => PageUtils.IsValidLicenseUrl(p.LicenseUrl))){

WriteLiteral("                <li>\r\n                    <strong>");


                       Write(licensePackage.Id);

WriteLiteral(" ");


                                          Write(licensePackage.Version);

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


                Write(PackageManagerResources.AuthorsLabel);

WriteLiteral(": <span class=\"package-author\">");


                                                                                    Write(String.Join(PackageManagerResources.WordSeparator, licensePackage.Authors));

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


                        Write(licensePackage.LicenseUrl);

WriteLiteral("\" target=\"_blank\">");


                                                                    Write(PackageManagerResources.ViewLicenseTerms);

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


            }

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


    }else {

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



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


    }


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


Write(PackageManagerResources.Disclaimer);

WriteLiteral("</p>    \r\n<fieldset class=\"no-border install\">\r\n    <input type=\"hidden\" name=\"so" +
"urce\" value=\"");


                                         Write(sourceName);

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


                                          Write(packageId);

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


                                          Write(version);

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


Write(AntiForgery.GetHtml());

WriteLiteral("\r\n\r\n    <input type=\"submit\" value=\"");


                           Write(PackageManagerResources.InstallPackage);

WriteLiteral("\" />\r\n    <input type=\"reset\" value=\"");


                          Write(PackageManagerResources.Cancel);

WriteLiteral("\" data-returnurl=\"");


                                                                           Write(packagesHomeUrl);

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


        }
    }
}
#pragma warning restore 1591
