Added RedirectUsingNamedRoute
[castle.git] / Samples / MonoRail / ActiveRecordIntegrationSample / Common.Models / Account.cs
blobd5846300f5a4fff19cbbb9cf06e63a07b91848c7
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 using Castle.Components.Validator;
17 namespace Common.Models
19 using System;
21 using Castle.ActiveRecord;
22 using Iesi.Collections;
24 [ActiveRecord("TSAS_Account")]
25 public class Account : ActiveRecordValidationBase
27 private int id;
28 private String name;
29 private String email;
30 private String password;
31 private String confirmationpassword;
32 private ProductLicense productLicense;
33 private ISet permissions;
35 public Account()
39 [PrimaryKey]
40 public int Id
42 get { return id; }
43 set { id = value; }
46 [Property, ValidateNonEmpty]
47 public string Name
49 get { return name; }
50 set { name = value; }
53 [Property, ValidateNonEmpty, ValidateEmail]
54 public string Email
56 get { return email; }
57 set { email = value; }
60 [Property, ValidateNonEmpty, ValidateSameAs("ConfirmationPassword")]
61 public string Password
63 get { return password; }
64 set { password = value; }
67 [ValidateNonEmpty]
68 public string ConfirmationPassword
70 get { return confirmationpassword; }
71 set { confirmationpassword = value; }
74 [BelongsTo("license_id")]
75 public ProductLicense ProductLicense
77 get { return productLicense; }
78 set { productLicense = value; }
81 [HasAndBelongsToMany( typeof(AccountPermission), Table="AccountAccountPermission",
82 ColumnRef="permission_id", ColumnKey="account_id", Inverse=false)]
83 public ISet Permissions
85 get { return permissions; }
86 set { permissions = value; }
89 public override string ToString()
91 return name;
94 public static Account[] FindAll()
96 return (Account[]) ActiveRecordBase.FindAll(typeof(Account));