#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
{
    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("~/Register.cshtml")]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorSingleFileGenerator", "1.0.0.0")]
    public class Register_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 Register_cshtml()
        {
        }
        protected System.Web.HttpApplication ApplicationInstance
        {
            get
            {
                return ((System.Web.HttpApplication)(Context.ApplicationInstance));
            }
        }
        public override void Execute()
        {


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



  
    Page.Title = AdminResources.RegisterTitle;
    var adminPath = SiteAdmin.AdminVirtualPath.TrimStart('~');
    Page.Desc = String.Format(CultureInfo.CurrentCulture, AdminResources.RegisterDesc, Html.Encode(adminPath));

    // If the password is already set the redirect to login
    if(AdminSecurity.HasAdminPassword()) {
        SiteAdmin.RedirectToLogin(Response);
        return;
    }

    if (IsPost) {
        AntiForgery.Validate();

        var password = Request.Form["password"];
        var reenteredPassword = Request.Form["repassword"];
        if (password.IsEmpty()) {
            ModelState.AddError("password", AdminResources.Validation_PasswordRequired); 
        }
        else if (password != reenteredPassword) {
            ModelState.AddError("repassword", AdminResources.Validation_PasswordsDoNotMatch);
        }

        if (ModelState.IsValid) {
            // Save the admin password
            if(AdminSecurity.SaveTemporaryPassword(password)) {
                // Get the return url
                var returnUrl = SiteAdmin.GetReturnUrl(Request) ?? SiteAdmin.AdminVirtualPath;

                // Redirect to the return url
                Response.Redirect(returnUrl);
            }
            else {
                // Add a validation error since creating the password.txt failed
                ModelState.AddFormError(AdminResources.AdminModuleRequiresAccessToAppData);
            }
            
        }
    }


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


Write(Html.ValidationSummary());

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


Write(AntiForgery.GetHtml());

WriteLiteral("\r\n<fieldset>\r\n    <ol>\r\n        <li class=\"password\">\r\n            <label for=\"pa" +
"ssword\">");


                             Write(AdminResources.EnterPassword);

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


       Write(Html.Password("password"));

WriteLiteral(" ");


                                  Write(Html.ValidationMessage("password", "*"));

WriteLiteral("\r\n        </li>\r\n        <li class=\"password\">\r\n            <label>");


              Write(AdminResources.ReenterPassword);

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


       Write(Html.Password("repassword"));

WriteLiteral(" ");


                                    Write(Html.ValidationMessage("repassword", "*"));

WriteLiteral("\r\n        </li>\r\n    </ol>\r\n    <p class=\"form-actions\">\r\n        <input type=\"su" +
"bmit\" value=\"");


                               Write(AdminResources.CreatePassword);

WriteLiteral("\" class=\"long-input\" />\r\n    </p>\r\n</fieldset>\r\n</form>\r\n");


        }
    }
}
#pragma warning restore 1591
