- Data:
- 2009-11-03 16:06:42 (16 years ago)
- Lokalizacja:
- trunk/eCard/eCardMVC
- Pliki:
-
- 10 zmodyfikowane
-
Platnosci.Core/Interface/IRepository.cs (zmodyfikowane) (3 diffs)
-
Platnosci.Core/Linq/Platnosci.cs (zmodyfikowane) (1 diff)
-
Platnosci.Core/Linq/Platnosci.designer.cs (zmodyfikowane) (2 diffs)
-
Platnosci.Core/Linq/PlatnosciDataContext.cs (zmodyfikowane) (1 diff)
-
Platnosci.Core/Linq/Repository.cs (zmodyfikowane) (3 diffs)
-
Platnosci.Core/Platnosci.Core.csproj (zmodyfikowane) (2 diffs)
-
Platnosci.Tests/Web/PlatnosciControllerTests.cs (zmodyfikowane) (1 diff)
-
Platnosci/Controllers/AccountController.cs (zmodyfikowane) (2 diffs)
-
Platnosci/Controllers/MerchantController.cs (zmodyfikowane) (3 diffs)
-
Platnosci/Controllers/PlatnoscController.cs (zmodyfikowane) (6 diffs)
Legenda:
- Bez zmian
- Dodane
- Usunięte
-
trunk/eCard/eCardMVC/Platnosci.Core/Interface/IRepository.cs
r866 r870 4 4 using System.Linq.Expressions; 5 5 using System.Text; 6 using Platnosci.Core.Linq; 6 7 7 8 namespace Platnosci.Core.Interface … … 16 17 17 18 void Delete(T entity); 18 19 19 20 void Update(T entity); 20 21 … … 36 37 37 38 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); 38 45 } 39 46 } -
trunk/eCard/eCardMVC/Platnosci.Core/Linq/Platnosci.cs
r866 r870 1 namespace Platnosci.Core 1 namespace Platnosci.Core 2 2 { 3 partial class PlatnosciDataContext 3 partial class PlatnosciDataContext 4 4 { 5 5 } -
trunk/eCard/eCardMVC/Platnosci.Core/Linq/Platnosci.designer.cs
r866 r870 22 22 using System.ComponentModel; 23 23 using System; 24 24 using Platnosci.Core.Interface; 25 25 26 26 [System.Data.Linq.Mapping.DatabaseAttribute(Name="BAZA_REKLAM_TEST")] 27 public partial class PlatnosciDataContext : System.Data.Linq.DataContext27 public partial class PlatnosciDataContext : DataContext 28 28 { 29 30 private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); 29 private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); 31 30 32 31 #region Extensibility Method Definitions … … 48 47 partial void DeletevPlatnosciEcard(vPlatnosciEcard instance); 49 48 #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 } 80 73 public System.Data.Linq.Table<PlatnosciEcard> PlatnosciEcards 81 74 { -
trunk/eCard/eCardMVC/Platnosci.Core/Linq/PlatnosciDataContext.cs
r866 r870 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using Platnosci.Core.Interface; 4 5 5 6 namespace Platnosci.Core.Linq 6 7 { 8 7 9 public partial class PlatnosciDataContext 8 10 { 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 47 12 } 48 13 } -
trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs
r867 r870 15 15 /// <typeparam name="T">The generic type representing the entity we are dealing with</typeparam> 16 16 /// <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 19 18 { 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; 21 22 23 public Repository(IDataContext dataContext) 24 { 25 _dataContext = dataContext; 26 } 22 27 public int Count() 23 28 { … … 57 62 return _dataContext.GetTable<T>().Where(expression).ToList(); 58 63 } 59 60 64 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 } 71 68 public void Delete(T entity) 72 69 { 73 if (entity != null) 74 { 75 _dataContext.GetTable<T>().DeleteOnSubmit(entity); 76 _dataContext.SubmitChanges(); 77 } 70 _dataContext.Insert(entity); 78 71 } 79 72 public void Update(T entity) … … 92 85 { 93 86 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 } 95 100 } 96 101 } -
trunk/eCard/eCardMVC/Platnosci.Core/Platnosci.Core.csproj
r866 r870 63 63 </ItemGroup> 64 64 <ItemGroup> 65 <Compile Include="Interface\IDataContext.cs" /> 65 66 <Compile Include="Interface\IIdentifiable.cs" /> 67 <Compile Include="Interface\IRep.cs" /> 66 68 <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" /> 69 71 <Compile Include="Linq\Payer.cs" /> 70 72 <Compile Include="Linq\Platnosci.cs"> … … 78 80 <Compile Include="Linq\PlatnosciDataContext.cs" /> 79 81 <Compile Include="Linq\PlatnosciEcard.cs" /> 82 <Compile Include="Linq\PotwierdzeniaEcard.cs" /> 83 <Compile Include="Linq\Rep.cs" /> 80 84 <Compile Include="Linq\Repository.cs" /> 81 <Compile Include="Linq\RepositoryPlatnosciEcard.cs" />82 <Compile Include="Linq\RepositoryPotwierdzeniaEcard.cs" />83 85 <Compile Include="Linq\vPlatnosciEcard.cs" /> 84 86 <Compile Include="Linq\Waluta.cs" /> -
trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs
r866 r870 17 17 class PlatnosciControllerTests 18 18 { 19 private string merchantNumber = "123";19 private string merchantNumber = "123"; 20 20 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() 23 55 { 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); 26 58 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")); 31 62 } 63 [Test] 64 public void AddPayment() 65 { 66 FakeDataContext fake = new FakeDataContext(); 67 IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake); 32 68 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); 38 73 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); 46 78 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")); 53 81 } 82 54 83 } 55 84 } 85 -
trunk/eCard/eCardMVC/Platnosci/Controllers/AccountController.cs
r866 r870 32 32 public AccountController() 33 33 { 34 _repository = new Repository<vPlatnosciEcard>( );34 _repository = new Repository<vPlatnosciEcard>(new DataContext1()); 35 35 FormsAuth = new FormsAuthenticationService(); 36 36 _context = new PlatnosciDataContext(); … … 65 65 else 66 66 { 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(); 68 69 platnosc = Login; 69 70 if (platnosc == null) return View(); -
trunk/eCard/eCardMVC/Platnosci/Controllers/MerchantController.cs
r868 r870 32 32 private string merchantId; 33 33 private readonly PlatnosciDataContext _context; 34 private readonly IRepository PE_rep;34 private readonly IRepository<PlatnosciEcard> _rep; 35 35 private FunkcjePlatnosci _func; 36 36 37 37 public MerchantController() 38 38 { 39 _rep = new Repository PlatnosciEcard();39 _rep = new Repository<PlatnosciEcard>(new DataContext1()); 40 40 _context = new PlatnosciDataContext(); 41 41 _func = new FunkcjePlatnosci(); … … 46 46 47 47 int id1 = Convert.ToInt32(payer.Id_faktury); 48 vPlatnosciEcard platnosc = _ context.FindInvoiceById(id1).SingleOrDefault();48 vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 49 49 50 50 if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name)) … … 64 64 65 65 string hash = GetHash(newPayment, systemKs); 66 hash = hash.Replace("\n",""); 67 if (hash == BAD_HASH || hash == "" ) return View("Error"); 66 68 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³atnoci. 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"; 76 71 77 72 string link = ConfigurationManager.AppSettings["StatusLink"]; -
trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs
r868 r870 12 12 using System.Web.UI; 13 13 using System.Threading; 14 using System.Data.Linq; 15 using System.Web.Configuration; 14 16 15 17 namespace Platnosci.Controllers … … 19 21 { 20 22 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; 22 26 private FunkcjePlatnosci _func; 23 27 28 24 29 public PlatnoscController() 25 30 { 26 31 _context = new PlatnosciDataContext(); 27 _rep = new Repository PotwierdzeniaEcard();32 _rep = new Repository<PotwierdzeniaEcard>(new DataContext1()); 28 33 _func = new FunkcjePlatnosci(); 34 } 35 public PlatnoscController(IDataContext datacontext){ 36 _rep = new Repository<PotwierdzeniaEcard>(datacontext); 37 _context1 = datacontext; 29 38 } 30 39 public ActionResult Show(string id, string language) … … 40 49 { 41 50 } 42 vPlatnosciEcard platnosc = _context.FindInvoiceById(id1).SingleOrDefault();43 51 52 vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 44 53 //sprawdzamy czy numer faktury dotyczy zalogowanego usera 45 54 ErrorViewData errorViewData = new ErrorViewData(); … … 55 64 } 56 65 57 var tablica_potwierdzenia = _ context.FindItemsByIdFaktury(id1);66 var tablica_potwierdzenia = _rep.FindItemsByIdFaktury(id1); 58 67 if (tablica_potwierdzenia.Count > 0) //platnosc za fakture zostala uregulowana 59 68 { … … 83 92 { 84 93 } 85 vPlatnosciEcard platnosc = _ context.FindInvoiceById(id1).SingleOrDefault();94 vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 86 95 ErrorViewData errorViewData = new ErrorViewData(); 87 96 if (platnosc == null) … … 130 139 //id1=0 -> error type = platnoscIsNotExist; 131 140 } 132 vPlatnosciEcard platnosc = _ context.FindInvoiceById(id1).SingleOrDefault();141 vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 133 142 ErrorViewData errorViewData = new ErrorViewData(); 134 143 if (platnosc == null)
