Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / OtherDbPost.cs
blob0211c863ad1ac683615dd41742208f6d5a26c036
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
17 using System;
18 using System.Collections;
20 using Castle.ActiveRecord.Tests.Model;
23 [ActiveRecord("PostTable")]
24 public class OtherDbPost : Test2ARBase
26 private int _id;
27 private String _title;
28 private String _contents;
29 private String _category;
30 private DateTime _created;
31 private bool _published;
32 private OtherDbBlog _blog;
34 public OtherDbPost()
38 public OtherDbPost(OtherDbBlog blog, String title, String contents, String category)
40 _blog = blog;
41 _title = title;
42 _contents = contents;
43 _category = category;
46 [PrimaryKey(PrimaryKeyType.Native)]
47 public int Id
49 get { return _id; }
50 set { _id = value; }
53 [Property]
54 public String Title
56 get { return _title; }
57 set { _title = value; }
60 [Property(ColumnType="StringClob")]
61 public String Contents
63 get { return _contents; }
64 set { _contents = value; }
67 [Property]
68 public String Category
70 get { return _category; }
71 set { _category = value; }
74 [BelongsTo("blogid")]
75 public OtherDbBlog Blog
77 get { return _blog; }
78 set { _blog = value; }
81 [Property("created")]
82 public DateTime Created
84 get { return _created; }
85 set { _created = value; }
88 [Property("published")]
89 public bool Published
91 get { return _published; }
92 set { _published = value; }
95 protected override bool BeforeSave(IDictionary state)
97 state["Created"] = DateTime.Now;
98 return true;
101 public static void DeleteAll()
103 ActiveRecordBase.DeleteAll( typeof(OtherDbPost) );
106 public static OtherDbPost[] FindAll()
108 return (OtherDbPost[]) ActiveRecordBase.FindAll( typeof(OtherDbPost) );
111 public static OtherDbPost Find(int id)
113 return (OtherDbPost) ActiveRecordBase.FindByPrimaryKey( typeof(OtherDbPost), id );
116 public void SaveWithException()
118 Save();
120 throw new ApplicationException("Fake Exception");