
namespace SilverlightDataApp.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Web.Ria;
    using System.Web.Ria.Data;
    using System.Web.DomainServices;
    using System.Data;


    // The MetadataTypeAttribute identifies RegTableMetadata as the class
    // that carries additional metadata for the RegTable class.
    [MetadataTypeAttribute(typeof(RegTable.RegTableMetadata))]
    public partial class RegTable
    {

#pragma warning disable 649    // temporarily disable compiler warnings about unassigned fields

        // This class allows you to attach custom attributes to properties
        // of the RegTable class.
        //
        // For example, the following marks the Xyz property as a
        // required field and specifies the format for valid values:
        //    [Required]
        //    [RegularExpression(“[A-Z][A-Za-z0-9]*”)]
        //    [StringLength(32)]
        //    public string Xyz;
        internal sealed class RegTableMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private RegTableMetadata()
            {
            }
            
            //Specifies the metadata for the fields of the database.

            //Here, the ID is not bindable, so it will not appear in the DataGrid or the DataForm
            //since it's a primary key and get's incremented automatically.
            [Bindable(false)]
            public int id;

            //The field is required and if not specified a value in the DataForm an error message get's generated.
            [Required(ErrorMessage = "Palun sisesta eesnimi")]
            public string eesnimi;

            [Required(ErrorMessage = "Palun sisesta perekonnanimi")]
            public string perenimi;

            //Besides a custom error message a range for the entered value is also specified. 
            [Required(ErrorMessage = "Palun sisesta vanus")]
            [Range(18, 99, ErrorMessage = "Vanus peab olema 18 ja 99 vahel")]
            public int vanus;

            [Required(ErrorMessage = "Palun sisesta oma eriala")]
            public string eriala;

            [Required(ErrorMessage = "Palun sisesta vaartus")]
            [Range(1, 5, ErrorMessage = "Kursus peab olema 1 ja 5 vahel")]
            public int kursus;

            public EntityState EntityState;
        }

#pragma warning restore 649    // re-enable compiler warnings about unassigned fields
    }
}
