1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Runtime.Serialization;
5: using System.ServiceModel;
6: using System.ServiceModel.Web;
7: using System.Text;
8:
9: namespace CustomerService
10: {
11: // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
12: // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
13: public class CustomerService : ICustomerService
14: {
15: List<Customer> lCustomersList = new List<Customer>();
16:
17: /// <summary>
18: /// Gets the selelected customer
19: /// </summary>
20: /// <param name="sCustomerID">ID of the selected customer</param>
21: /// <returns></returns>
22: public List<Customer> getACustomer(string sCustomerID)
23: {
24: //Generate Customer Data
25: generateCustomerData();
26:
27:
28: //Querying the customer
29: var qCustomer = (from c in lCustomersList
30: where c.IDCustomer == sCustomerID
31: select c).ToList();
32: //Filling the returned data
33: List<Customer> lrCustomer = qCustomer;
34:
35: return lrCustomer;
36: }
37:
38: public List<Customer> getAllCustomers()
39: {
40: generateCustomerData();
41: List<Customer> lAllCustomers = new List<Customer>();
42:
43: //Querying the customers
44: var qCustomers = (from c in lCustomersList
45: select c).ToArray();
46: foreach (var qc in qCustomers)
47: {
48: Customer tCustomer = new Customer();
49: tCustomer.IDCustomer = qc.IDCustomer;
50: tCustomer.sCustomerName = qc.sCustomerName;
51: tCustomer.sCustomerAddress = qc.sCustomerAddress;
52: tCustomer.sCustomerEMail = qc.sCustomerEMail;
53: tCustomer.sCustomerPhone = qc.sCustomerPhone;
54:
55: lAllCustomers.Add(tCustomer);
56: }
57:
58: return lAllCustomers;
59: }
60: /// <summary>
61: /// This method generates customer data for the service
62: /// </summary>
63: private void generateCustomerData()
64: {
65: Customer cCustomer1 = new Customer();
66: cCustomer1.IDCustomer = "1";
67: cCustomer1.sCustomerName = "Juan Carlos González";
68: cCustomer1.sCustomerAddress = "C/ Camilo Alonso Vega 41 7 D 39007 Santander";
69: cCustomer1.sCustomerEMail = "jgonzalez@gruposodercan.es";
70: cCustomer1.sCustomerPhone = "647 391 399";
71:
72: lCustomersList.Add(cCustomer1);
73:
74: Customer cCustomer2 = new Customer();
75: cCustomer2.IDCustomer = "2";
76: cCustomer2.sCustomerName = "Ángel Acha";
77: cCustomer2.sCustomerAddress = "C/ Joaquín Costa s/n 39005 Santander";
78: cCustomer2.sCustomerEMail = "aacha@gruposodercan.es";
79: cCustomer2.sCustomerPhone = "942 760 620";
80:
81: lCustomersList.Add(cCustomer2);
82: }
83: }
84: }