using System;
using MAC.Types;
using MAC.Types.User;
using MAC.Types.Internet;
using MAC.Models.Attributes;
using MAC.Models.Attributes.Validations;

namespace MAC.Models {
  [TableName("<%= table_name %>")]
  [UrlName("<%= table_name.parameterize %>")]
  public partial class <%= name.camelize %> : BaseModel<<%= name.camelize %>> {
    <% fields.each do |field| %>

      <% if field.key?("relationship") && field["relationship"] == true  %>
      [DatabaseField("<%= field["name"] %>")]
      public Integer <%= field["name"].camelize + "Id" %> { get; set; }
      public virtual <%= field["name"].camelize %> <%= "A_" + field["name"].camelize %> {
        get {
          return <%= field["name"].camelize %>.Get(<%= field["name"].camelize(:upper) + "Id" %>);
        }

        set {
          <%= field["name"].camelize  + "Id" %> = (int) value.Id;
        }
      }
      <% else %>
      [DatabaseField("<%= field["name"] %>")]
      public <%= field["type"] %> <%= field["name"].camelize  %> { get; set; }
      <% end %>
    <% end %>
  }

}
