Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / GenericModel / Post.cs
blob351f6d30e542821370530a4a2b73e95b5e208dd7
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 namespace Castle.ActiveRecord.Tests.Model.GenericModel
17 using System;
18 using System.Collections;
20 using NHibernate.Expressions;
22 [ActiveRecord("PostTable")]
23 public class Post : ActiveRecordBase<Post>
25 private int _id;
26 private String _title;
27 private String _contents;
28 private String _category;
29 private DateTime _created;
30 private bool _published;
31 private Blog _blog;
33 public Post()
37 public Post(Blog blog, String title, String contents, String category)
39 _blog = blog;
40 _title = title;
41 _contents = contents;
42 _category = category;
45 [PrimaryKey]
46 public int Id
48 get { return _id; }
49 set { _id = value; }
52 [Property]
53 public String Title
55 get { return _title; }
56 set { _title = value; }
59 [Property(ColumnType="StringClob")]
60 public String Contents
62 get { return _contents; }
63 set { _contents = value; }
66 [Property]
67 public String Category
69 get { return _category; }
70 set { _category = value; }
73 [BelongsTo("blogid")]
74 public Blog Blog
76 get { return _blog; }
77 set { _blog = value; }
80 [Property("created")]
81 public DateTime Created
83 get { return _created; }
84 set { _created = value; }
87 [Property("published")]
88 public bool Published
90 get { return _published; }
91 set { _published = value; }
94 public void SaveWithException()
96 Save();
98 throw new ApplicationException("Fake Exception");
101 protected override bool BeforeSave(IDictionary state) {
102 state["Created"] = DateTime.Now;
103 return true;
106 public static Post[] CustomSlicedFind(ICriterion criteria, int firstResult, int maxResults)
108 return SlicedFindAll(firstResult, maxResults, criteria);