annotate SilverlightExampleApp/SilverlightExampleApp.Web/Repositories/ClientMockRepository.cs @ 57:558c09d76726

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