Added RedirectUsingNamedRoute
[castle.git] / Samples / MindDump / Castle.Applications.MindDump / Services / AccountService.cs
bloba5bba0cf9439aa16141e099bd2f083d60ff453bd
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.Applications.MindDump.Services
17 using System;
19 using Castle.Applications.MindDump.Dao;
20 using Castle.Applications.MindDump.Model;
22 using Castle.Services.Transaction;
24 [Transactional]
25 public class AccountService
27 private AuthorDao _authorDao;
28 private BlogDao _blogDao;
29 private IMindDumpEventPublisher _publisher;
31 public AccountService(AuthorDao authorDao, BlogDao blogDao)
33 _authorDao = authorDao;
34 _blogDao = blogDao;
37 public IMindDumpEventPublisher EventPublisher
39 get { return _publisher; }
40 set { _publisher = value; }
43 /// <summary>
44 /// This method creates an author and a blog for him,
45 /// if something fails, we need to recover both. Thus
46 /// we require that this method is transactional.
47 /// </summary>
48 /// <param name="blog"></param>
49 [Transaction(TransactionMode.Requires)]
50 public virtual void CreateAccountAndBlog( Blog blog )
52 _authorDao.Create( blog.Author );
53 _blogDao.Create( blog );
55 if (EventPublisher != null) EventPublisher.NotifyBlogAdded( blog );
58 public virtual void UpdateAccount( Author author )
60 _authorDao.Update( author );
63 public virtual void UpdateBlog( Blog blog )
65 _blogDao.Update( blog );
68 public virtual Author ObtainAuthor( String login )
70 return _authorDao.Find(login);