root/trunk/Wierszowki/Wierszowki.Services/AuthorService.cs @ 752

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

wiersz

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    public class AuthorService : BaseService
11    {
12        public void Update(Author author)
13        {
14            var errors = DataAnnotationsValidationRunner.GetErrors(author);
15            if (errors.Any())
16                throw new RulesException(errors);
17           
18            var authorToUpdate = DataContext.GetAuthorById(author.Id);
19            authorToUpdate.FirstName = author.FirstName;
20            authorToUpdate.LastName = author.LastName;
21            authorToUpdate.EmploymentTypeId = author.EmploymentTypeId;
22            DataContext.SubmitChanges();
23        }
24
25        public void Create(Author author)
26        {
27            var errors = DataAnnotationsValidationRunner.GetErrors(author);
28            if (errors.Any())
29                throw new RulesException(errors);
30
31            DataContext.Authors.InsertOnSubmit(author);
32            DataContext.SubmitChanges();
33        }
34    }
35}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.