<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.AuthorViewData>" %>
<%@ Import namespace="Wierszowki.Core.Validation"%> 
<asp:Content ID="js" ContentPlaceHolderID="jsContent" runat="server">
    <script src="../../Scripts/jquery-1.3.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.3.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.blockUI.js" type="text/javascript"></script>
    <script src="../../Scripts/date.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.datePicker.js" type="text/javascript"></script>
    <script src="../../Scripts/spiffy.js" type="text/javascript"></script>
    <script src="../../Scripts/jHelper.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.validate.js" type="text/javascript" ></script>
    <script src="../../Scripts/xVal.jquery.validate.js" type="text/javascript"></script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Edytuj autora
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        $(function() {
            jQuery.validator.setDefaults({
	           success: "valid"
            });                      	            
	        $("#myform").validate({
                rules: {
                    "Author.FirstName":         { required: true },
                    "Author.LastName":          { required: true },
                    "Author.EmploymentTypeId":  { required: true, range:[1,10]}
                },
                messages: {
                    "Author.FirstName":         { required: "Proszę podać imię autora." },
                    "Author.LastName":          { required: "Proszę podać nazwisko autora." },
                    "Author.EmploymentTypeId":  { required: "Proszę wybrać typ zatrudnienia.",range:"dshvsh" }
                }
             });
             $("#myform").change(function() {
                $("#myform").valid();
             });           
         });
    </script>
    <h2>Edytuj autora</h2>

    <%= Html.ValidationSummary("Edycja się nie powiodła. Proszę poprawić błędy i spróbować ponownie.") %>

    <% using (Html.BeginForm("Edit", "Author", Model.Author, FormMethod.Post, new { id = "myform" }))
       {%>

        <fieldset>
            <legend>Dane autora</legend>
            <%= Html.Hidden("Author.Id", Model.Author.Id)%>
            <div class="formitem">            
                <label for="FirstName">Imię:</label>
                <%= Html.TextBox("Author.FirstName", Model.Author.FirstName)%>
                <%= Html.ValidationMessage("Author.FirstName", "*")%>
                <br />
            </div>
            <div class="formitem">           
                <label for="LastName">Nazwisko:</label>
                <%= Html.TextBox("Author.LastName", Model.Author.LastName)%>
                <%= Html.ValidationMessage("Author.LastName", "*")%>
                <br />
            </div>
            <div class="formitem"> 
                <label for="LastName">Zatrudnienie:</label>
                <%= Html.DropDownList("Author.EmploymentTypeId", ViewData.Model.EmploymentTypeList, "-- proszę wybrać --") %>
                <%= Html.ValidationMessage("Author.EmploymentTypeId", "*")%>
                <br />
            </div>
            <div>
                <input type="submit" value="Aktualizuj" />
            </div>
        </fieldset>

    <% } %>

    <div>
        <%=Html.ActionLink("Powrót do listy autorów", "Index") %>
        <%=Html.ClientSideValidation<AuthorValidation>("Author")%>
    </div>
</asp:Content>