comparison SilverlightExampleApp/SilverlightExampleApp.Web/Repositories/ClientMockRepository.cs @ 49:502f5f365649

Initial load for Silverlight Example Application
author Steven Hollidge <stevenhollidge@hotmail.com>
date Tue, 17 Apr 2012 17:57:52 +0100
parents
children
comparison
equal deleted inserted replaced
48:d617b54e1f47 49:502f5f365649
1 using System.Collections.Generic;
2 using System.Linq;
3 using SilverlightExampleApp.Interfaces.Models;
4 using SilverlightExampleApp.Web.Factories;
5
6 namespace SilverlightExampleApp.Web.Repositories
7 {
8 public class ClientMockRepository : IRepository<IClient>
9 {
10 public IList<IClient> Clients { get; set; }
11
12 public ClientMockRepository()
13 {
14 Clients = ClientFactory.GetAll();
15 }
16
17 #region IRepository<Client> Members
18
19 public IClient Get(int id)
20 {
21 return Clients.FirstOrDefault(c => id == c.Id);
22 }
23
24 public IList<IClient> GetAll()
25 {
26 return Clients;
27 }
28
29 public void Insert(IClient item)
30 {
31 Clients.Add(item);
32 }
33
34 public void Update(IClient item)
35 {
36 var client = Clients.FirstOrDefault(c => item.Id == c.Id);
37 client.FirstName = item.FirstName;
38 client.FamilyName = item.FamilyName;
39 client.Title = item.Title;
40 client.Residence = item.Residence;
41 }
42
43 public void Delete(IClient item)
44 {
45 var client = Clients.FirstOrDefault(c => item.Id == c.Id);
46 Clients.Remove(client);
47 }
48
49 #endregion
50 }
51 }