root/branches/Emisje/Wierszowki/Wierszowki.Services/AuthorService.cs @ 838

Wersja 838, 1.1 KB (wprowadzona przez marek, 17 years temu)

re #195 - merged with latest trunk

Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Wierszowki.Core.Linq;
6using xVal.ServerSide;
7
8namespace Wierszowki.Services
9{
10   
11    public class AuthorService : BaseService
12    {
13        public void Update(Author author)
14        {
15            var errors = DataAnnotationsValidationRunner.GetErrors(author);
16            if (errors.Any())
17                throw new RulesException(errors);
18           
19            var authorToUpdate = DataContext.GetAuthorById(author.Id);
20            authorToUpdate.FirstName = author.FirstName;
21            authorToUpdate.LastName = author.LastName;
22            authorToUpdate.EmploymentTypeId = author.EmploymentTypeId;
23            DataContext.SubmitChanges();
24        }
25
26        public void Create(Author author)
27        {
28            var errors = DataAnnotationsValidationRunner.GetErrors(author);
29            if (errors.Any())
30                throw new RulesException(errors);
31
32            DataContext.Authors.InsertOnSubmit(author);
33            DataContext.SubmitChanges();
34        }
35    }
36}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.