Zbiór zmian 896 dla trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs
- Data:
- 2009-11-24 12:24:57 (16 years ago)
- Pliki:
-
- 1 zmodyfikowane
-
trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs (zmodyfikowane) (3 diffs)
Legenda:
- Bez zmian
- Dodane
- Usunięte
-
trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs
r888 r896 4 4 using System.Web; 5 5 using Platnosci.Core.Interface; 6 using Platnosci.Core.Linq; 6 7 7 namespace Platnosci. Core.Linq8 namespace Platnosci.Tests.Web 8 9 { 9 10 public class FakeDataContext : IDataContext 10 11 { 11 private List<vPlatnosciEcard> listaPlatnosci = new List<vPlatnosciEcard>(); 12 private List<PotwierdzeniaEcard> listaPotwierdzenia = new List<PotwierdzeniaEcard>(); 13 private List<PlatnosciEcard> listaPl = new List<PlatnosciEcard>(); 14 private List<object> lista = new List<object>(); 12 private List<PlatnosciEcard> listaPayment = new List<PlatnosciEcard>(); 13 15 14 private string code_Ok = "payment_deposited"; //transakcja potwierdzona do rozliczenia 16 private string code_Bad = "payment_declined"; //transakcja odrzucona 17 18 public vPlatnosciEcard DodajPlatnosc(int id, string numer, string nip) 19 { 20 vPlatnosciEcard p = new vPlatnosciEcard(); 21 p.ID_faktury = id; 22 p.Faktura_Numer = numer; 23 p.nip = nip; 24 25 return p; 26 } 27 public PotwierdzeniaEcard DodajPotwierdzenie(string code, int ordernumber) 28 { 29 PotwierdzeniaEcard potwierdzenie = new PotwierdzeniaEcard(); 30 potwierdzenie.CURRENTSTATE = code; 31 potwierdzenie.ORDERNUMBER = ordernumber; 32 33 return potwierdzenie; 34 } 35 public PlatnosciEcard createNewPayment(int ordernumber, bool status, DateTime data, int id_faktury) 36 { 37 PlatnosciEcard platnosc = new PlatnosciEcard(); 38 platnosc.ORDERNUMBER = ordernumber; 39 platnosc.Status = status; 40 platnosc.Status_data = data; 41 platnosc.IDFaktury = id_faktury; 42 43 return platnosc; 44 } 45 public FakeDataContext() 46 { 47 listaPlatnosci.Add(DodajPlatnosc(1,"1","123")); 48 listaPlatnosci.Add(DodajPlatnosc(2, "2", "aaa")); 49 } 50 //public FakeDataContext(int fake) 51 //{ 52 // if (fake == 1) 53 // { 54 // listaPlatnosci.Add(DodajPlatnosc(1000, "abcd", "12345")); 55 // listaPl.Add(createNewPayment(9999, true, DateTime.Now, 1000)); 56 // listaPotwierdzenia.Add(DodajPotwierdzenie(code_Ok, 9999)); 57 // } 58 // else if (fake == 2) 59 // { 60 // listaPl.Add(createNewPayment(9999, false, DateTime.Now, 1000)); 61 // } 62 //} 63 64 65 private readonly List<object> _dataStore = new List<object>(); 15 16 private readonly List<object> lista = new List<object>(); 17 private Function _f = new Function(); 18 66 19 67 20 public IQueryable<T> GetTable<T>() where T : class 68 21 { 69 var query = _dataStore.Where(objects => typeof(T).IsAssignableFrom(objects.GetType()));22 var query = lista.Where(objects => typeof(T).IsAssignableFrom(objects.GetType())); 70 23 return query.Select(o => (T)o).AsQueryable(); 71 24 } … … 73 26 public void Insert<T>(T item) where T : class 74 27 { 75 _dataStore.Add(item);28 lista.Add(item); 76 29 } 77 30 78 31 public void Delete<T>(T item) where T : class 79 32 { 80 _dataStore.Remove(item);33 lista.Remove(item); 81 34 } 82 35 … … 97 50 { 98 51 } 99 100 public IQueryable<vPlatnosciEcard> FindInvoiceById(int id)101 {102 List<object> lp = lista;103 for (int i = 0; i < lp.Count(); i++)104 {105 if (lp[i].GetType() == typeof(vPlatnosciEcard))106 {107 listaPlatnosci.Add((vPlatnosciEcard)lp[i]);108 }109 }110 lista.Clear();111 112 var query = from l in listaPlatnosci113 where l.ID_faktury == id114 select l;115 116 return query.AsQueryable();117 }118 52 public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer) 119 53 { 120 List<object> lp = lista; 121 for (int i = 0; i < lp.Count(); i++) 122 { 123 if (lp[i].GetType() == typeof(vPlatnosciEcard)) 124 { 125 listaPlatnosci.Add((vPlatnosciEcard)lp[i]); 126 } 127 } 128 lista.Clear(); 129 130 var query = from l in listaPlatnosci 131 where l.nip == nip && l.Faktura_Numer == numer 132 select l; 133 134 return query.AsQueryable(); 54 throw new NotImplementedException(); 135 55 } 136 56 public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury) 137 57 { 138 List<PotwierdzeniaEcard> listazaplaconych = new List<PotwierdzeniaEcard>(); 139 for (int j = 0; j < listaPl.Count(); j++) 58 59 PlatnosciEcard platnosc = _f.createNewPayment(123456, true, DateTime.Now, 123); 60 List<PlatnosciEcard> payment = new List<PlatnosciEcard>(); 61 List<PotwierdzeniaEcard> listaConfirm = new List<PotwierdzeniaEcard>(); 62 listaConfirm.Add((PotwierdzeniaEcard)lista[0]); 63 payment.Add(platnosc); 64 65 List<PotwierdzeniaEcard> new_confirm = new List<PotwierdzeniaEcard>(); 66 67 if (platnosc.IDFaktury == idFaktury) 140 68 { 141 for (int i = 0; i < listaPotwierdzenia.Count(); i++) 142 { 143 if (listaPl[j].IDFaktury == idFaktury && listaPl[j].ORDERNUMBER == listaPotwierdzenia[i].ORDERNUMBER && listaPotwierdzenia[i].CURRENTSTATE == code_Ok) listazaplaconych.Add(listaPotwierdzenia[i]); 144 } 69 if (listaConfirm[0].ORDERNUMBER == platnosc.ORDERNUMBER && listaConfirm[0].CURRENTSTATE == code_Ok) 70 new_confirm.Add(listaConfirm[0]); 145 71 } 146 return listazaplaconych; 147 } 148 public IQueryable<PlatnosciEcard> FindPaymentByOrdernumber(int ordernumber) 149 { 150 var query = from l in listaPl 151 where l.ORDERNUMBER == ordernumber 152 select l; 153 154 return query.AsQueryable(); 72 System.Diagnostics.Debug.WriteLine("lista" + new_confirm.Count()); 73 return new_confirm; 155 74 } 156 75 }
