|
Wersja 752, 1.1 KB
(wprowadzona przez marek, 17 years temu)
|
|
wiersz
|
| Rev | Line | |
|---|
| [752] | 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Linq;
|
|---|
| 4 | using System.Text;
|
|---|
| 5 | using Wierszowki.Core.Linq;
|
|---|
| 6 | using xVal.ServerSide;
|
|---|
| 7 |
|
|---|
| 8 | namespace 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.