diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SilverlightExampleApp/SilverlightExampleApp.Web/Repositories/ClientMockRepository.cs	Tue Apr 17 17:57:52 2012 +0100
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+using System.Linq;
+using SilverlightExampleApp.Interfaces.Models;
+using SilverlightExampleApp.Web.Factories;
+
+namespace SilverlightExampleApp.Web.Repositories
+{
+    public class ClientMockRepository : IRepository<IClient>
+    {
+        public IList<IClient> Clients { get; set; }
+
+        public ClientMockRepository()
+        {
+            Clients = ClientFactory.GetAll();
+        }
+
+        #region IRepository<Client> Members
+
+        public IClient Get(int id)
+        {
+            return Clients.FirstOrDefault(c => id == c.Id);
+        }
+
+        public IList<IClient> GetAll()
+        {
+            return Clients;
+        }
+
+        public void Insert(IClient item)
+        {
+            Clients.Add(item);
+        }
+
+        public void Update(IClient item)
+        {
+            var client = Clients.FirstOrDefault(c => item.Id == c.Id);
+            client.FirstName = item.FirstName;
+            client.FamilyName = item.FamilyName;
+            client.Title = item.Title;
+            client.Residence = item.Residence;
+        }
+
+        public void Delete(IClient item)
+        {
+            var client = Clients.FirstOrDefault(c => item.Id == c.Id);
+            Clients.Remove(client);
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file