#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 System.Text.RegularExpressions;
    using NuGet;
    
    [System.Web.WebPages.PageVirtualPathAttribute("~/packages/Uninstall.cshtml")]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorSingleFileGenerator", "1.0.0.0")]
    public class packages_Uninstall_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_Uninstall_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\r\n");


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

    WebProjectManager projectManager;
    try {
        projectManager = new WebProjectManager(PackageManagerModule.ActiveSource.Source, PackageManagerModule.SiteRoot);
    } catch (Exception exception) {

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


                              Write(exception.Message);

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


        return;
    }

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

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

                                 
        return; 
    }

    // Set up layout values
    var packagesHomeUrl = Href(PageUtils.GetPackagesHome(), Request.Url.Query);
    Page.SectionTitle = String.Format(CultureInfo.CurrentCulture, PackageManagerResources.UninstallPackageDesc, package.GetDisplayName());

    if (IsPost) {
        AntiForgery.Validate();
        bool removeDependencies = Request.Form["removeDependencies"].AsBool(false);
        try { 
            projectManager.UninstallPackage(package, removeDependencies: removeDependencies);
        } catch (Exception exception) {
            ModelState.AddFormError(exception.Message);
        }
        
        if (ModelState.IsValid) {
            Response.Redirect(packagesHomeUrl + "&action-completed=Uninstall");
        }
        else {
            
       Write(Html.ValidationSummary(String.Format(CultureInfo.CurrentCulture, PackageManagerResources.PackageUninstallationError, package.GetDisplayName())));

                                                                                                                                                            
        }
        return;
    }



  
    var encodedPackageName = Html.Encode(package.GetDisplayName());

WriteLiteral("    <h4>");


   Write(Html.Raw(String.Format(CultureInfo.CurrentCulture, PackageManagerResources.AreYouSureUninstall, encodedPackageName)));

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




WriteLiteral("<form method=\"post\" action=\"\" id=\"submitForm\">\r\n<fieldset class=\"no-border\">\r\n   " +
" ");


Write(AntiForgery.GetHtml());

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");


     if (package.Dependencies.Any()) {

WriteLiteral("        <div>\r\n            <label><input type=\"checkbox\" name=\"removeDependencies" +
"\" value=\"true\" checked=\"checked\"/>");


                                                                                               Write(PackageManagerResources.RemoveDependencies);

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



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


    }

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


                           Write(PackageManagerResources.UninstallPackage);

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


                          Write(PackageManagerResources.Cancel);

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


                                                                           Write(packagesHomeUrl);

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


        }
    }
}
#pragma warning restore 1591
