| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Linq;
|
|---|
| 4 | using System.Web;
|
|---|
| 5 | using Platnosci.Core.Interface;
|
|---|
| 6 | using System.Data.Linq;
|
|---|
| 7 |
|
|---|
| 8 | namespace Platnosci.Core.Linq
|
|---|
| 9 | {
|
|---|
| 10 | public class DataContext1 : IDataContext
|
|---|
| 11 | {
|
|---|
| 12 | private readonly PlatnosciDataContext _dataContext;
|
|---|
| 13 | private List<object> listaPlatnosci = new List<object>();
|
|---|
| 14 | public DataContext1()
|
|---|
| 15 | {
|
|---|
| 16 | _dataContext = new PlatnosciDataContext();
|
|---|
| 17 | }
|
|---|
| 18 | public IQueryable<T> GetTable<T>() where T : class
|
|---|
| 19 | {
|
|---|
| 20 | return _dataContext.GetTable<T>();
|
|---|
| 21 | }
|
|---|
| 22 | public void Insert<T>(T item) where T : class
|
|---|
| 23 | {
|
|---|
| 24 | _dataContext.GetTable<T>().InsertOnSubmit(item);
|
|---|
| 25 | _dataContext.SubmitChanges();
|
|---|
| 26 | }
|
|---|
| 27 | public void Delete<T>(T item) where T : class
|
|---|
| 28 | {
|
|---|
| 29 | if (item != null)
|
|---|
| 30 | {
|
|---|
| 31 | _dataContext.GetTable<T>().DeleteOnSubmit(item);
|
|---|
| 32 | _dataContext.SubmitChanges();
|
|---|
| 33 | }
|
|---|
| 34 | }
|
|---|
| 35 | public void SubmitChanges()
|
|---|
| 36 | {
|
|---|
| 37 | _dataContext.SubmitChanges();
|
|---|
| 38 | }
|
|---|
| 39 | public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer)
|
|---|
| 40 | {
|
|---|
| 41 | var query = from i in _dataContext.vPlatnosciEcards
|
|---|
| 42 | where (i.nip == nip && i.Faktura_Numer == numer)
|
|---|
| 43 | select i;
|
|---|
| 44 | return query;
|
|---|
| 45 | }
|
|---|
| 46 | public IQueryable<vPlatnosciEcard> FindInvoiceById(int id)
|
|---|
| 47 | {
|
|---|
| 48 | var query = from i in _dataContext.vPlatnosciEcards
|
|---|
| 49 | where i.ID_faktury == id
|
|---|
| 50 | select i;
|
|---|
| 51 | return query;
|
|---|
| 52 | }
|
|---|
| 53 | public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury)
|
|---|
| 54 | {
|
|---|
| 55 | var query = from vp in _dataContext.PlatnosciEcards
|
|---|
| 56 | where vp.IDFaktury == idFaktury && vp.Status == true
|
|---|
| 57 | orderby vp.IDFaktury descending
|
|---|
| 58 | select vp;
|
|---|
| 59 |
|
|---|
| 60 | query.ToList();
|
|---|
| 61 | var tablica = new List<PotwierdzeniaEcard>();
|
|---|
| 62 |
|
|---|
| 63 | foreach (var pt in query)
|
|---|
| 64 | {
|
|---|
| 65 | var query2 = from ps in _dataContext.PotwierdzeniaEcards
|
|---|
| 66 | where ps.ORDERNUMBER == pt.ORDERNUMBER && ps.CURRENTSTATE == "payment_deposited"
|
|---|
| 67 | orderby ps.id
|
|---|
| 68 | select ps;
|
|---|
| 69 |
|
|---|
| 70 | for (var i = 0; i < query2.ToList().Count; i++)
|
|---|
| 71 | {
|
|---|
| 72 | tablica.Add(query2.ToList()[i]);
|
|---|
| 73 | }
|
|---|
| 74 | }
|
|---|
| 75 | return tablica;
|
|---|
| 76 | }
|
|---|
| 77 | public List<object> getlista()
|
|---|
| 78 | {
|
|---|
| 79 | return listaPlatnosci;
|
|---|
| 80 | }
|
|---|
| 81 | public IQueryable<PlatnosciEcard> FindPaymentByOrdernumber(int ordernumber)
|
|---|
| 82 | {
|
|---|
| 83 | var query = from l in _dataContext.PlatnosciEcards
|
|---|
| 84 | where l.ORDERNUMBER == ordernumber
|
|---|
| 85 | select l;
|
|---|
| 86 |
|
|---|
| 87 | return query;
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|