Zbiór zmian 949

Pokaż
Ignoruj:
Data:
2009-12-11 16:57:08 (16 years ago)
Autor:
marek
Opis:

re #215 - drobny refactoring

Lokalizacja:
trunk/eCard/eCardMVC
Pliki:
19 zmodyfikowane
1 przeniesione

Legenda:

Bez zmian
Dodane
Usunięte
  • trunk/eCard/eCardMVC/Platnosci.Core/Interface/IDataContext.cs

    r918 r949  
    22using System.Collections.Generic; 
    33using System.Linq; 
    4 using System.Web; 
    54using Platnosci.Core.Linq; 
    6 using System.Text;  
    75 
    86namespace Platnosci.Core.Interface 
  • trunk/eCard/eCardMVC/Platnosci.Core/Interface/IIdentifiable.cs

    r867 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using System.Linq; 
    4 using System.Web; 
    5  
    6 namespace Platnosci.Core.Interface 
     1namespace Platnosci.Core.Interface 
    72{ 
    83    public interface IIdentifiable 
  • trunk/eCard/eCardMVC/Platnosci.Core/Interface/IRepository.cs

    r918 r949  
    33using System.Linq; 
    44using System.Linq.Expressions; 
    5 using System.Text; 
    65using Platnosci.Core.Linq; 
    76 
  • trunk/eCard/eCardMVC/Platnosci.Core/Interface/ITranslateManager.cs

    r927 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using System.Linq; 
    4 using System.Text; 
    5  
    6 namespace Platnosci.Core.Interface 
     1namespace Platnosci.Core.Interface 
    72{ 
    83    public interface ITranslateManager 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/DataContext.cs

    r918 r949  
    22using System.Collections.Generic; 
    33using System.Linq; 
    4 using System.Web; 
    54using Platnosci.Core.Interface; 
    6 using System.Data.Linq; 
    75 
    86namespace Platnosci.Core.Linq 
    97{ 
    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  
     8    public class DataContext : IDataContext 
     9    { 
     10        private readonly PlatnosciDataContext _dataContext; 
     11        private readonly List<object> _listaPlatnosci = new List<object>(); 
     12 
     13        public DataContext() 
     14        { 
     15            _dataContext = new PlatnosciDataContext(); 
     16        } 
     17 
     18        public IQueryable<T> GetTable<T>() where T : class 
     19        { 
     20            return _dataContext.GetTable<T>(); 
     21        } 
     22 
     23        public void Insert<T>(T item) where T : class 
     24        { 
     25            _dataContext.GetTable<T>().InsertOnSubmit(item); 
     26            _dataContext.SubmitChanges(); 
     27        } 
     28 
     29        public void Delete<T>(T item) where T : class 
     30        { 
     31            if (item == null) return; 
     32 
     33            _dataContext.GetTable<T>().DeleteOnSubmit(item); 
     34            _dataContext.SubmitChanges(); 
     35        } 
     36 
     37        public void SubmitChanges() 
     38        { 
     39            _dataContext.SubmitChanges(); 
     40        } 
     41 
     42        public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer) 
     43        { 
     44            var query = from i in _dataContext.vPlatnosciEcards 
     45                        where (i.nip == nip && i.Faktura_Numer == numer) 
     46                        select i; 
     47            return query; 
     48        } 
     49 
     50        public IQueryable<vPlatnosciEcard> FindInvoiceById(int id) 
     51        { 
     52            var query = from i in _dataContext.vPlatnosciEcards 
     53                        where i.ID_faktury == id 
     54                        select i; 
     55            return query; 
     56        } 
     57 
     58        public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury) 
     59        { 
     60            var query = _dataContext.PlatnosciEcards 
     61                            .Where(vp => vp.IDFaktury == idFaktury && vp.Status == true) 
     62                            .OrderByDescending(vp => vp.IDFaktury); 
     63 
     64            query.ToList(); 
     65 
     66            var tablica = new List<PotwierdzeniaEcard>(); 
     67 
     68            foreach (var pt in query) 
    2869            { 
    29                 if (item != null) 
     70                var ecard = pt; 
     71                var query2 = _dataContext.PotwierdzeniaEcards 
     72                                .Where(ps => ps.ORDERNUMBER == ecard.ORDERNUMBER && ps.CURRENTSTATE == "payment_deposited") 
     73                                .OrderBy(ps => ps.id); 
     74 
     75                for (var i = 0; i < query2.ToList().Count; i++) 
    3076                { 
    31                     _dataContext.GetTable<T>().DeleteOnSubmit(item); 
    32                     _dataContext.SubmitChanges(); 
     77                    tablica.Add(query2.ToList()[i]); 
    3378                } 
    3479            } 
    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; 
    5980 
    60                 query.ToList(); 
    61                 var tablica = new List<PotwierdzeniaEcard>(); 
     81            return tablica; 
     82        } 
    6283 
    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; 
     84        public List<object> Getlista() 
     85        { 
     86            return _listaPlatnosci; 
     87        } 
    6988 
    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; 
     89        public IQueryable<PlatnosciEcard> FindPaymentByOrdernumber(int ordernumber) 
     90        { 
     91            var query = from l in _dataContext.PlatnosciEcards 
     92                        where l.ORDERNUMBER == ordernumber 
     93                        select l; 
    8694 
    87                 return query; 
    88             } 
    89             public int GetOrdernumber(string description, int? idfaktury, DateTime? data) 
    90             { 
    91                 int ordernumber = 0; 
     95            return query; 
     96        } 
    9297 
    93                 var query = from l in _dataContext.PlatnosciEcards 
    94                             where l.ORDERDESCRIPTION == description && l.IDFaktury == idfaktury && l.Data == data 
    95                             select l; 
    96                  
    97                 List<PlatnosciEcard> pl = query.ToList(); 
    98                 if (pl.Count > 0 && pl[0].ORDERNUMBER > 0) ordernumber = pl[0].ORDERNUMBER; 
    99                 return ordernumber; 
    100             } 
     98        public int GetOrdernumber(string description, int? idfaktury, DateTime? data) 
     99        { 
     100            var ordernumber = 0; 
     101 
     102            var query = from l in _dataContext.PlatnosciEcards 
     103                        where l.ORDERDESCRIPTION == description && l.IDFaktury == idfaktury && l.Data == data 
     104                        select l; 
     105 
     106            var pl = query.ToList(); 
     107             
     108            if (pl.Count > 0 && pl[0].ORDERNUMBER > 0) ordernumber = pl[0].ORDERNUMBER; 
     109             
     110            return ordernumber; 
     111        } 
    101112    } 
    102113} 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Merchant.cs

    r934 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using System.Linq; 
    4 using System.Web; 
    5  
    6 namespace Platnosci.Core.Linq 
     1namespace Platnosci.Core.Linq 
    72{ 
    83    public class Merchant 
    94    { 
    10         public string merchntId { get; set; } 
    11         public string merchantPassword { get; set; } 
     5        public string Id { get; set; } 
     6        public string Password { get; set; } 
    127    } 
    138} 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Payer.cs

    r915 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using System.Linq; 
    4 using System.Web; 
    5  
    6 namespace Platnosci.Core.Linq 
     1namespace Platnosci.Core.Linq 
    72{ 
    83    public class Payer 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Platnosci.designer.cs

    r870 r949  
    2525         
    2626        [System.Data.Linq.Mapping.DatabaseAttribute(Name="BAZA_REKLAM_TEST")] 
    27         public partial class PlatnosciDataContext : DataContext 
     27        public partial class PlatnosciDataContext : System.Data.Linq.DataContext 
    2828        { 
    2929        private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/PlatnosciDataContext.cs

    r870 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using System.Linq; 
    4 using Platnosci.Core.Interface; 
    5  
    6 namespace Platnosci.Core.Linq 
     1namespace Platnosci.Core.Linq 
    72{ 
    83     
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/PlatnosciEcard.cs

    r867 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using Platnosci.Core.Interface; 
     1using Platnosci.Core.Interface; 
    42 
    53namespace Platnosci.Core.Linq 
     
    97        public int Id 
    108        { 
    11             get 
    12             { 
    13                 return this.ORDERNUMBER; 
    14             } 
     9            get { return ORDERNUMBER; } 
    1510        } 
    1611 
    1712    } 
    1813} 
    19  
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/PotwierdzeniaEcard.cs

    r872 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using System.Linq; 
    4 using System.Web; 
    5 using Platnosci.Core.Interface; 
     1using Platnosci.Core.Interface; 
    62 
    73namespace Platnosci.Core.Linq 
     
    117        public int Id 
    128        { 
    13             get 
    14             { 
    15                 return this.id; 
    16             } 
     9            get { return id; } 
    1710        } 
    1811    } 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs

    r918 r949  
    11using System; 
    22using System.Collections.Generic; 
    3 using System.Data.Linq; 
    43using System.Linq; 
    54using System.Linq.Expressions; 
    6 using System.Text; 
    75using Platnosci.Core.Interface; 
    86 
     
    1715    public class Repository<T> : IRepository<T> where T : class, IIdentifiable 
    1816    { 
    19         protected readonly IDataContext _dataContext; 
     17        protected readonly IDataContext DataContext; 
    2018 
    2119        public Repository(IDataContext dataContext) 
    2220        { 
    23             _dataContext = dataContext; 
     21            DataContext = dataContext; 
    2422        }   
    2523        public int Count() 
    2624        { 
    27             return _dataContext.GetTable<T>().Count(); 
     25            return DataContext.GetTable<T>().Count(); 
    2826        } 
    2927        public int Count(Expression<Func<T, bool>> expression) 
    3028        { 
    31             return _dataContext.GetTable<T>().Count(expression); 
     29            return DataContext.GetTable<T>().Count(expression); 
    3230        } 
    3331        public T FindOne(int id) 
     
    3735        public T FindOne(Expression<Func<T, bool>> expression) 
    3836        { 
    39             return _dataContext.GetTable<T>().Where(expression).SingleOrDefault(); 
     37            return DataContext.GetTable<T>().Where(expression).SingleOrDefault(); 
    4038        } 
    4139 
     
    5452        public IList<T> FindAll() 
    5553        { 
    56             return _dataContext.GetTable<T>().ToList(); 
     54            return DataContext.GetTable<T>().ToList(); 
    5755        } 
    5856        public IList<T> FindAll(Expression<Func<T, bool>> expression) 
    5957        { 
    60             return _dataContext.GetTable<T>().Where(expression).ToList(); 
     58            return DataContext.GetTable<T>().Where(expression).ToList(); 
    6159        } 
    6260        public void Insert(T entity) 
    6361            { 
    64                 _dataContext.Insert(entity);             
     62                DataContext.Insert(entity);             
    6563            } 
    6664        public void Delete(T entity) 
    6765        { 
    68             _dataContext.Delete(entity); 
     66            DataContext.Delete(entity); 
    6967        } 
    7068        public void SubmitChanges() 
    7169        { 
    72             _dataContext.SubmitChanges(); 
     70            DataContext.SubmitChanges(); 
    7371        } 
    7472        public IQueryable<T> Find(int id) 
    7573        { 
    76             return _dataContext.GetTable<T>().Where(t => t.Id == id); 
     74            return DataContext.GetTable<T>().Where(t => t.Id == id); 
    7775        } 
    7876        public IQueryable<T> Find(Expression<Func<T, bool>> expression) 
    7977        { 
    80             return _dataContext.GetTable<T>().Where(expression);         
     78            return DataContext.GetTable<T>().Where(expression);         
    8179        } 
    8280        public IQueryable<T> Find() 
    8381        { 
    84             return _dataContext.GetTable<T>(); 
     82            return DataContext.GetTable<T>(); 
    8583        } 
    8684        public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer) 
    8785        { 
    88             return _dataContext.FindInvoiceByNipNumber(nip, numer); 
     86            return DataContext.FindInvoiceByNipNumber(nip, numer); 
    8987        } 
    9088        public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury) 
    9189        { 
    92             return _dataContext.FindItemsByIdFaktury(idFaktury); 
     90            return DataContext.FindItemsByIdFaktury(idFaktury); 
    9391        } 
    9492        public int GetOrdernumber(string description, int? idfaktury, DateTime? data) 
    9593        { 
    96             return _dataContext.GetOrdernumber(description, idfaktury, data); 
     94            return DataContext.GetOrdernumber(description, idfaktury, data); 
    9795        } 
    9896    } 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Translation.cs

    r927 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using System.Linq; 
    4 using System.Web; 
     1using System.Web; 
    52using Platnosci.Core.Interface; 
    63 
     
    118        public string Translate(string className, string keyName) 
    129        { 
    13             string strName = HttpContext.GetGlobalResourceObject(className, keyName).ToString(); 
     10            var strName = HttpContext.GetGlobalResourceObject(className, keyName).ToString(); 
    1411            return strName; 
    1512        } 
    16  
    17          
    1813    } 
    1914} 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Waluta.cs

    r866 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using System.Linq; 
    4 using System.Web; 
    5  
    6 namespace Platnosci.Core.Linq 
     1namespace Platnosci.Core.Linq 
    72{ 
    83    public class Waluta 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/vPlatnosciEcard.cs

    r867 r949  
    1 using System; 
    2 using System.Collections.Generic; 
    3 using Platnosci.Core.Interface; 
     1using Platnosci.Core.Interface; 
    42 
    53namespace Platnosci.Core.Linq 
     
    75    public partial class vPlatnosciEcard : IIdentifiable 
    86    { 
    9         public string FullName  
    10         {  
    11             get  
    12             {  
    13                 return LastName + " " + FirstName;  
    14             } 
     7        public string FullName 
     8        { 
     9            get { return LastName + " " + FirstName; } 
    1510        } 
    1611 
    17         public int Id 
    18         { 
    19             get { return this.ID_faktury; } 
    20         } 
     12        public int Id { get { return ID_faktury; } } 
    2113    } 
    2214} 
    23  
    24  
  • trunk/eCard/eCardMVC/Platnosci.Core/Platnosci.Core.csproj

    r934 r949  
    7171    <Compile Include="Interface\IRepository.cs" /> 
    7272    <Compile Include="Interface\ITranslateManager.cs" /> 
    73     <Compile Include="Linq\DataContext1.cs" /> 
     73    <Compile Include="Linq\DataContext.cs" /> 
    7474    <Compile Include="Linq\Merchant.cs" /> 
    7575    <Compile Include="Linq\Payer.cs" /> 
  • trunk/eCard/eCardMVC/Platnosci/Controllers/AccountController.cs

    r948 r949  
    2323        public AccountController() 
    2424        { 
    25             _repository = new Repository<vPlatnosciEcard>(new DataContext1()); 
     25            _repository = new Repository<vPlatnosciEcard>(new DataContext()); 
    2626            FormsAuth = new FormsAuthenticationService(); 
    2727            _funkcjePlatnosci = new FunkcjePlatnosci(); 
  • trunk/eCard/eCardMVC/Platnosci/Controllers/MerchantController.cs

    r948 r949  
    2828        public MerchantController() 
    2929        { 
    30             _repVPayment = new Repository<vPlatnosciEcard>(new DataContext1()); 
    31             _repPayment = new Repository<PlatnosciEcard>(new DataContext1()); 
     30            _repVPayment = new Repository<vPlatnosciEcard>(new DataContext()); 
     31            _repPayment = new Repository<PlatnosciEcard>(new DataContext()); 
    3232            _funkcjePlatnosci = new FunkcjePlatnosci(); 
    3333            _translateManager = new Translation(); 
     
    7979            linkOk += "/" + newPayment.IDFaktury + "?o=" + orderek; 
    8080 
    81             if (merchant != null && !String.IsNullOrEmpty(merchant.merchntId)) 
     81            if (merchant != null && !String.IsNullOrEmpty(merchant.Id)) 
    8282                SendRequest(newPayment, hash, merchant, linkFail, linkOk); 
    8383            else  
     
    130130            var dane = "&orderDescription=&amount=" + platnosc.AMOUNT; 
    131131            dane += "&currency=" + platnosc.CURRENCY; 
    132             dane += string.Format("&merchantId={0}&password={1}", merchant.merchntId, merchant.merchantPassword); 
     132            dane += string.Format("&merchantId={0}&password={1}", merchant.Id, merchant.Password); 
    133133 
    134134            var bdata = System.Text.Encoding.ASCII.GetBytes(dane); 
     
    154154            var dane = "&AMOUNT=" + m.AMOUNT + "&CURRENCY=" + m.CURRENCY + "&ORDERNUMBER=" + m.ORDERNUMBER; 
    155155            dane += "&NAME=" + m.NAME + "&SURNAME=" + m.SURNAME + "&LANGUAGE=" + m.LANGUAGE + "&CHARSET=ISO-8859-2"; 
    156             dane += "&COUNTRY=616&PAYMENTTYPE=CARDS&JS=1&HASH=" + hash + "&MERCHANTID=" + merchant.merchntId + "&AUTODEPOSIT=" + m.AUTODEPOSIT; 
     156            dane += "&COUNTRY=616&PAYMENTTYPE=CARDS&JS=1&HASH=" + hash + "&MERCHANTID=" + merchant.Id + "&AUTODEPOSIT=" + m.AUTODEPOSIT; 
    157157            dane += "&LINKFAIL=" + linkfail + "&LINKOK=" + linkok + "&SESSIONID=" + m.SESSIONID; 
    158158            Response.Redirect(adres + dane); 
     
    174174            if (systemKs == "2") 
    175175            { 
    176                 merchant.merchntId = "171485000"; 
    177                 merchant.merchantPassword = "ashSeth2"; 
     176                merchant.Id = "171485000"; 
     177                merchant.Password = "ashSeth2"; 
    178178            } 
    179179            else 
    180180            { 
    181                 merchant.merchntId = "170906000"; 
    182                 merchant.merchantPassword = "JaYpqfs0"; 
     181                merchant.Id = "170906000"; 
     182                merchant.Password = "JaYpqfs0"; 
    183183            }               
    184184            return merchant; 
  • trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs

    r948 r949  
    2121        public PlatnoscController() 
    2222        { 
    23             _repVPayment = new Repository<vPlatnosciEcard>(new DataContext1()); 
    24             _repPayment = new Repository<PlatnosciEcard>(new DataContext1()); 
    25             _repConfirm = new Repository<PotwierdzeniaEcard>(new DataContext1()); 
     23            _repVPayment = new Repository<vPlatnosciEcard>(new DataContext()); 
     24            _repPayment = new Repository<PlatnosciEcard>(new DataContext()); 
     25            _repConfirm = new Repository<PotwierdzeniaEcard>(new DataContext()); 
    2626            _funkcjePlatnosci = new FunkcjePlatnosci(); 
    2727            _translateManager = new Translation();          
  • trunk/eCard/eCardMVC/Platnosci/Views/Platnosc/Form.aspx

    r911 r949  
    1313     <br/> 4. ValidationCode: <%=Html.TextBox("VALIDATIONCODE","000")%>       
    1414     <br/> 5. APPROVALCODE: <%=Html.TextBox("APPROVALCODE","123")%> 
    15      <br/> 6. AUTHTIME: <%=Html.TextBox("AUTHTIME")%> 
     15     <br/> 6. AUTHTIME: <%=Html.TextBox("AUTHTIME", DateTime.Now)%> 
    1616     <br/> 7. BIN: <%=Html.TextBox("BIN","1234")%> 
    1717     <br/> 8. COMMTYPE: <%=Html.TextBox("COMMTYPE","anbjbj")%>