Zbiór zmian 870 dla trunk

Pokaż
Ignoruj:
Data:
2009-11-03 16:06:42 (16 years ago)
Autor:
alina
Opis:

re #215

Lokalizacja:
trunk/eCard/eCardMVC
Pliki:
10 zmodyfikowane

Legenda:

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

    r866 r870  
    44using System.Linq.Expressions; 
    55using System.Text; 
     6using Platnosci.Core.Linq; 
    67 
    78namespace Platnosci.Core.Interface 
     
    1617 
    1718        void Delete(T entity); 
    18  
     19         
    1920        void Update(T entity); 
    2021 
     
    3637 
    3738        IQueryable<T> Find(Expression<Func<T, bool>> expression); 
     39 
     40        IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer); 
     41 
     42        IQueryable<vPlatnosciEcard> FindInvoiceById(int id); 
     43 
     44        List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury); 
    3845    } 
    3946} 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Platnosci.cs

    r866 r870  
    1 namespace Platnosci.Core 
     1namespace Platnosci.Core     
    22{ 
    3     partial class PlatnosciDataContext 
     3    partial class PlatnosciDataContext  
    44    { 
    55    } 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Platnosci.designer.cs

    r866 r870  
    2222        using System.ComponentModel; 
    2323        using System; 
    24          
     24    using Platnosci.Core.Interface; 
    2525         
    2626        [System.Data.Linq.Mapping.DatabaseAttribute(Name="BAZA_REKLAM_TEST")] 
    27         public partial class PlatnosciDataContext : System.Data.Linq.DataContext 
     27        public partial class PlatnosciDataContext : DataContext 
    2828        { 
    29                  
    30                 private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); 
     29        private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); 
    3130                 
    3231    #region Extensibility Method Definitions 
     
    4847    partial void DeletevPlatnosciEcard(vPlatnosciEcard instance); 
    4948    #endregion 
    50     public PlatnosciDataContext() :  
    51                                 base(global::Platnosci.Core.Properties.Settings.Default.BAZA_REKLAM_TESTConnectionString, mappingSource) 
    52                 { 
    53                         OnCreated(); 
    54                 } 
    55                  
    56                 public PlatnosciDataContext(string connection) :  
    57                                 base(connection, mappingSource) 
    58                 { 
    59                         OnCreated(); 
    60                 } 
    61                  
    62                 public PlatnosciDataContext(System.Data.IDbConnection connection) :  
    63                                 base(connection, mappingSource) 
    64                 { 
    65                         OnCreated(); 
    66                 } 
    67                  
    68                 public PlatnosciDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :  
    69                                 base(connection, mappingSource) 
    70                 { 
    71                         OnCreated(); 
    72                 } 
    73                  
    74                 public PlatnosciDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :  
    75                                 base(connection, mappingSource) 
    76                 { 
    77                         OnCreated(); 
    78                 } 
    79                  
     49       public PlatnosciDataContext() :base(global::Platnosci.Core.Properties.Settings.Default.BAZA_REKLAM_TESTConnectionString, mappingSource) 
     50                { 
     51           OnCreated(); 
     52                } 
     53                 
     54                public PlatnosciDataContext(string connection) : base(connection, mappingSource) 
     55                { 
     56            OnCreated(); 
     57                } 
     58                 
     59                public PlatnosciDataContext(System.Data.IDbConnection connection) : base(connection, mappingSource) 
     60                { 
     61            OnCreated(); 
     62                } 
     63                 
     64                public PlatnosciDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :base(connection, mappingSource) 
     65                { 
     66            OnCreated(); 
     67                } 
     68                 
     69                public PlatnosciDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :base(connection, mappingSource) 
     70                { 
     71            OnCreated(); 
     72                } 
    8073                public System.Data.Linq.Table<PlatnosciEcard> PlatnosciEcards 
    8174                { 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/PlatnosciDataContext.cs

    r866 r870  
    22using System.Collections.Generic; 
    33using System.Linq; 
     4using Platnosci.Core.Interface; 
    45 
    56namespace Platnosci.Core.Linq 
    67{ 
     8     
    79    public partial class PlatnosciDataContext 
    810    { 
    9         public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer) 
    10         { 
    11             var query = from i in vPlatnosciEcards 
    12                 where (i.nip == nip && i.Faktura_Numer == numer) 
    13                 select i; 
    14             return query;             
    15         } 
    16         public IQueryable<vPlatnosciEcard> FindInvoiceById(int id) 
    17         { 
    18             var query = from i in vPlatnosciEcards 
    19                         where i.ID_faktury == id 
    20                         select i; 
    21             return query; 
    22         } 
    23         public List<PotwierdzeniaEcard>FindItemsByIdFaktury(int idFaktury) 
    24         { 
    25             var query = from vp in PlatnosciEcards 
    26                         where vp.IDFaktury == idFaktury && vp.Status == true 
    27                         orderby vp.IDFaktury descending 
    28                         select vp; 
    29  
    30             query.ToList(); 
    31             var tablica = new List<PotwierdzeniaEcard>(); 
    32              
    33             foreach (var pt in query) 
    34             { 
    35                 var query2 = from ps in PotwierdzeniaEcards 
    36                              where ps.ORDERNUMBER == pt.ORDERNUMBER && ps.VALIDATIONCODE == "000" 
    37                              orderby ps.id 
    38                              select ps; 
    39                 
    40                 for (var i = 0; i < query2.ToList().Count; i++) 
    41                 { 
    42                     tablica.Add(query2.ToList()[i]); 
    43                 }               
    44             }             
    45             return tablica; 
    46         } 
     11        
    4712    } 
    4813} 
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs

    r867 r870  
    1515    /// <typeparam name="T">The generic type representing the entity we are dealing with</typeparam> 
    1616    /// <remarks>We use a 1 to 1 mapping of entity -> SQL table</remarks> 
    17     public sealed class Repository<T> : IRepository<T> 
    18       where T : class, IIdentifiable 
     17    public class Repository<T> : IRepository<T> where T : class, IIdentifiable 
    1918    { 
    20         private readonly PlatnosciDataContext _dataContext = new PlatnosciDataContext(); 
     19       // private readonly PlatnosciDataContext _dataContext = new PlatnosciDataContext(); 
     20        //private PlatnosciDataContext _dataContext = new PlatnosciDataContext(); 
     21        protected readonly IDataContext _dataContext; 
    2122 
     23        public Repository(IDataContext dataContext) 
     24        { 
     25            _dataContext = dataContext; 
     26        }   
    2227        public int Count() 
    2328        { 
     
    5762            return _dataContext.GetTable<T>().Where(expression).ToList(); 
    5863        } 
    59  
    6064        public void Insert(T entity) 
    61         { 
    62             //DataContext.GetTable<T>().InsertOnSubmit(entity); 
    63             //DataContext.SubmitChanges(); 
    64  
    65             //using (DataContext dc = new WierszowkiDataContext()) 
    66             //{ 
    67                 _dataContext.GetTable<T>().InsertOnSubmit(entity); 
    68                 _dataContext.SubmitChanges(); 
    69             //} 
    70         } 
     65            { 
     66                _dataContext.Insert(entity);             
     67            } 
    7168        public void Delete(T entity) 
    7269        { 
    73             if (entity != null) 
    74             { 
    75                 _dataContext.GetTable<T>().DeleteOnSubmit(entity); 
    76                 _dataContext.SubmitChanges(); 
    77             } 
     70            _dataContext.Insert(entity); 
    7871        } 
    7972        public void Update(T entity) 
     
    9285        { 
    9386            return _dataContext.GetTable<T>(); 
    94         }        
     87        } 
     88        public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer) 
     89        { 
     90            return _dataContext.FindInvoiceByNipNumber(nip, numer); 
     91        } 
     92        public IQueryable<vPlatnosciEcard> FindInvoiceById(int id) 
     93        { 
     94            return _dataContext.FindInvoiceById(id); 
     95        } 
     96        public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury) 
     97        { 
     98            return _dataContext.FindItemsByIdFaktury(idFaktury); 
     99        } 
    95100    } 
    96101} 
  • trunk/eCard/eCardMVC/Platnosci.Core/Platnosci.Core.csproj

    r866 r870  
    6363  </ItemGroup> 
    6464  <ItemGroup> 
     65    <Compile Include="Interface\IDataContext.cs" /> 
    6566    <Compile Include="Interface\IIdentifiable.cs" /> 
     67    <Compile Include="Interface\IRep.cs" /> 
    6668    <Compile Include="Interface\IRepository.cs" /> 
    67     <Compile Include="Interface\IRepositoryPE.cs" /> 
    68     <Compile Include="Interface\IRepositoryPT.cs" /> 
     69    <Compile Include="Linq\DataContext1.cs" /> 
     70    <Compile Include="Linq\FakeDataContext.cs" /> 
    6971    <Compile Include="Linq\Payer.cs" /> 
    7072    <Compile Include="Linq\Platnosci.cs"> 
     
    7880    <Compile Include="Linq\PlatnosciDataContext.cs" /> 
    7981    <Compile Include="Linq\PlatnosciEcard.cs" /> 
     82    <Compile Include="Linq\PotwierdzeniaEcard.cs" /> 
     83    <Compile Include="Linq\Rep.cs" /> 
    8084    <Compile Include="Linq\Repository.cs" /> 
    81     <Compile Include="Linq\RepositoryPlatnosciEcard.cs" /> 
    82     <Compile Include="Linq\RepositoryPotwierdzeniaEcard.cs" /> 
    8385    <Compile Include="Linq\vPlatnosciEcard.cs" /> 
    8486    <Compile Include="Linq\Waluta.cs" /> 
  • trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs

    r866 r870  
    1717    class PlatnosciControllerTests 
    1818    { 
    19         private string merchantNumber = "123"; 
     19         private string merchantNumber = "123"; 
    2020 
    21         [TearDown] 
    22         public void TearDown() 
     21         /*[TearDown] 
     22         public void TearDown() 
     23         { 
     24             IRepository<PotwierdzeniaEcard> _rep = new Repository<PotwierdzeniaEcard>(); 
     25             var potwierdzeniaEcard = _rep.Find(p => p.MERCHANTNUMBER == merchantNumber); 
     26 
     27             foreach (var pe in potwierdzeniaEcard) 
     28             { 
     29                 _rep.Delete(pe); 
     30             } 
     31         } 
     32        */ 
     33         [Test] 
     34         public void Status_Saves_Correct_Transaction() 
     35         { 
     36             
     37             var orderNumber = 9999; 
     38             FakeDataContext fake = new FakeDataContext(); 
     39             var builder = new TestControllerBuilder(); 
     40             var controller = new PlatnoscController(fake); 
     41             builder.InitializeController(controller); 
     42             builder.Form.Add("MERCHANTNUMBER", merchantNumber.ToString()); 
     43             builder.Form.Add("AUTHTIME", DateTime.Now.ToString()); 
     44             builder.Form.Add("DATATRANSMISJI", DateTime.Now.ToString()); 
     45             builder.Form.Add("ORDERNUMBER", orderNumber.ToString()); 
     46 
     47             var result = controller.Status(); 
     48 
     49             IRepository<PotwierdzeniaEcard> _rep = new Repository<PotwierdzeniaEcard>(fake);             
     50             var potwierdzeniaEcard = _rep.Find(p => p.ORDERNUMBER == orderNumber).First(); 
     51             Assert.That(potwierdzeniaEcard.MERCHANTNUMBER, Is.EqualTo(merchantNumber));             
     52         }  
     53        [Test] 
     54        public void NumerFaktury() 
    2355        { 
    24             IRepositoryPT _rep = new RepositoryPotwierdzeniaEcard(); 
    25             var potwierdzeniaEcard = _rep.Find(p => p.MERCHANTNUMBER == merchantNumber); 
     56             FakeDataContext fake = new FakeDataContext(); 
     57             IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake); 
    2658 
    27             foreach (var pe in potwierdzeniaEcard) 
    28             { 
    29                 _rep.Delete(pe); 
    30             } 
     59             vPlatnosciEcard platnosc = new vPlatnosciEcard(); 
     60             platnosc = _rep.FindInvoiceById(1).SingleOrDefault(); 
     61             Assert.That(platnosc.Faktura_Numer, Is.EqualTo("222/2")); 
    3162        } 
     63        [Test] 
     64        public void AddPayment() 
     65        { 
     66            FakeDataContext fake = new FakeDataContext(); 
     67            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake); 
    3268 
    33         [Test] 
    34         public void Status_Saves_Correct_Transaction() 
    35         { 
    36              
    37             var orderNumber = 9999; 
     69            vPlatnosciEcard platnosc = new vPlatnosciEcard(); 
     70            platnosc.ID_faktury = 13; 
     71            platnosc.nip = "nipek"; 
     72            _rep.Insert(platnosc); 
    3873 
    39             var builder = new TestControllerBuilder(); 
    40             var controller = new PlatnoscController(); 
    41             builder.InitializeController(controller); 
    42             builder.Form.Add("MERCHANTNUMBER", merchantNumber.ToString()); 
    43             builder.Form.Add("AUTHTIME", DateTime.Now.ToString()); 
    44             builder.Form.Add("DATATRANSMISJI", DateTime.Now.ToString()); 
    45             builder.Form.Add("ORDERNUMBER", orderNumber.ToString()); 
     74            vPlatnosciEcard pl1 = new vPlatnosciEcard(); 
     75            pl1.ID_faktury = 14; 
     76            pl1.nip = "vv"; 
     77            _rep.Insert(pl1); 
    4678 
    47             var result = controller.Status(); 
    48  
    49             IRepositoryPT _rep = new RepositoryPotwierdzeniaEcard(); 
    50             var potwierdzeniaEcard = _rep.Find(p => p.ORDERNUMBER == orderNumber).First(); 
    51             Assert.That(potwierdzeniaEcard.MERCHANTNUMBER, Is.EqualTo(merchantNumber)); 
    52              
     79            vPlatnosciEcard pl = _rep.FindInvoiceById(13).SingleOrDefault(); 
     80            Assert.That(pl.nip, Is.EqualTo("nipek")); 
    5381        } 
     82         
    5483    } 
    5584} 
     85 
  • trunk/eCard/eCardMVC/Platnosci/Controllers/AccountController.cs

    r866 r870  
    3232        public AccountController() 
    3333        { 
    34             _repository = new Repository<vPlatnosciEcard>(); 
     34            _repository = new Repository<vPlatnosciEcard>(new DataContext1()); 
    3535            FormsAuth = new FormsAuthenticationService(); 
    3636            _context = new PlatnosciDataContext(); 
     
    6565            else 
    6666            { 
    67                 var Login = _context.FindInvoiceByNipNumber(nip, numer_faktury).SingleOrDefault(); 
     67                var Login = _repository.FindInvoiceByNipNumber(nip, numer_faktury).SingleOrDefault(); 
     68                    //_context.FindInvoiceByNipNumber(nip, numer_faktury).SingleOrDefault(); 
    6869                platnosc = Login; 
    6970                if (platnosc == null) return View(); 
  • trunk/eCard/eCardMVC/Platnosci/Controllers/MerchantController.cs

    r868 r870  
    3232        private string merchantId; 
    3333        private readonly PlatnosciDataContext _context; 
    34         private readonly IRepositoryPE _rep; 
     34        private readonly IRepository<PlatnosciEcard> _rep; 
    3535        private FunkcjePlatnosci _func; 
    3636 
    3737        public MerchantController() 
    3838        {    
    39             _rep = new RepositoryPlatnosciEcard(); 
     39            _rep = new Repository<PlatnosciEcard>(new DataContext1()); 
    4040            _context = new PlatnosciDataContext(); 
    4141            _func = new FunkcjePlatnosci(); 
     
    4646 
    4747            int id1 = Convert.ToInt32(payer.Id_faktury); 
    48             vPlatnosciEcard platnosc = _context.FindInvoiceById(id1).SingleOrDefault(); 
     48            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 
    4949             
    5050            if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name)) 
     
    6464 
    6565            string hash = GetHash(newPayment, systemKs); 
     66            hash = hash.Replace("\n",""); 
     67            if (hash == BAD_HASH  || hash == "" ) return View("Error"); 
    6668 
    67             hash = hash.Replace("\n",""); 
    68             if (hash == BAD_HASH  || hash == "" ) 
    69             { 
    70                 return View("Error"); //nie mo¿na po³¹czyæ siê z serverem p³atnoœci. Proszê spróbowaæ jeszcze raz. 
    71             } 
    72             if (platnosc.SystemKsiegowyId == 1) 
    73                 merchantId = "170906000"; 
    74             else 
    75                 merchantId = "171485000"; 
     69            if (systemKs == "1") merchantId = "170906000"; 
     70                else merchantId = "171485000"; 
    7671 
    7772            string link = ConfigurationManager.AppSettings["StatusLink"]; 
  • trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs

    r868 r870  
    1212using System.Web.UI; 
    1313using System.Threading; 
     14using System.Data.Linq; 
     15using System.Web.Configuration; 
    1416 
    1517namespace Platnosci.Controllers 
     
    1921    { 
    2022        private readonly PlatnosciDataContext _context; 
    21         private readonly IRepositoryPT _rep; 
     23        private readonly IDataContext _context1; 
     24        private readonly IRepository<PotwierdzeniaEcard> _rep; 
     25        private readonly IRep<PotwierdzeniaEcard> _repository; 
    2226        private FunkcjePlatnosci _func; 
    2327 
     28 
    2429        public PlatnoscController() 
    2530        { 
    2631            _context = new PlatnosciDataContext(); 
    27             _rep = new RepositoryPotwierdzeniaEcard(); 
     32            _rep = new Repository<PotwierdzeniaEcard>(new DataContext1());  
    2833            _func = new FunkcjePlatnosci(); 
     34        } 
     35        public PlatnoscController(IDataContext datacontext){ 
     36            _rep = new Repository<PotwierdzeniaEcard>(datacontext); 
     37            _context1 = datacontext; 
    2938        } 
    3039        public ActionResult Show(string id, string language) 
     
    4049            { 
    4150            } 
    42             vPlatnosciEcard platnosc = _context.FindInvoiceById(id1).SingleOrDefault(); 
    43  
     51            
     52            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 
    4453            //sprawdzamy czy numer faktury dotyczy zalogowanego usera 
    4554            ErrorViewData errorViewData = new ErrorViewData(); 
     
    5564            } 
    5665             
    57             var tablica_potwierdzenia = _context.FindItemsByIdFaktury(id1); 
     66            var tablica_potwierdzenia = _rep.FindItemsByIdFaktury(id1); 
    5867            if (tablica_potwierdzenia.Count > 0) //platnosc za fakture zostala uregulowana 
    5968            { 
     
    8392            { 
    8493            } 
    85             vPlatnosciEcard platnosc = _context.FindInvoiceById(id1).SingleOrDefault(); 
     94            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 
    8695            ErrorViewData errorViewData = new ErrorViewData(); 
    8796            if (platnosc == null) 
     
    130139                //id1=0 -> error type =  platnoscIsNotExist; 
    131140            } 
    132             vPlatnosciEcard platnosc = _context.FindInvoiceById(id1).SingleOrDefault(); 
     141            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 
    133142            ErrorViewData errorViewData = new ErrorViewData(); 
    134143            if (platnosc == null)