Index: trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs (revision 870)
+++ trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs (revision 871)
@@ -23,17 +23,38 @@
         private readonly IDataContext _context1;
         private readonly IRepository<PotwierdzeniaEcard> _rep;
-        private readonly IRep<PotwierdzeniaEcard> _repository;
+        private readonly IRepository<PlatnosciEcard> _repPl;
         private FunkcjePlatnosci _func;
-
+        private string userIdentity = "";
+        private string weryfikacja = "";
+        private string brakdanych = "";
+        private string zaplacono = "";
+        private string err_imie = "";
+        private string err_nazwisko = "";
+        
+
+        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
+        {            
+            base.Initialize(requestContext);
+            userIdentity = HttpContext.User.Identity.Name;
+            weryfikacja = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString();
+            brakdanych = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString();
+            zaplacono = HttpContext.GetGlobalResourceObject("tlumaczenia", "zaplacono").ToString();
+            err_imie = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_imieWK").ToString();
+            err_nazwisko = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_nazwiskoWK").ToString();           
+        }       
 
         public PlatnoscController()
         {
             _context = new PlatnosciDataContext();
-            _rep = new Repository<PotwierdzeniaEcard>(new DataContext1()); 
+            _rep = new Repository<PotwierdzeniaEcard>(new DataContext1());
+            _repPl = new Repository<PlatnosciEcard>(new DataContext1());
             _func = new FunkcjePlatnosci();
+                      
         }
         public PlatnoscController(IDataContext datacontext){
             _rep = new Repository<PotwierdzeniaEcard>(datacontext);
+            _repPl = new Repository<PlatnosciEcard>(datacontext);
             _context1 = datacontext;
+            _func = new FunkcjePlatnosci();            
         }
         public ActionResult Show(string id, string language)
@@ -49,16 +70,15 @@
             {
             }
-           
+          
             vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
-            //sprawdzamy czy numer faktury dotyczy zalogowanego usera
             ErrorViewData errorViewData = new ErrorViewData();
             if (platnosc == null)
             {
-               errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString();
+               errorViewData.error = brakdanych;
                return View("Error1", errorViewData);                
             }
-            else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name))
-            {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString();
+            else if (!_func.UserIdentity(platnosc, userIdentity))
+            {
+                errorViewData.error = weryfikacja;
                 return View("Error1", errorViewData);
             }
@@ -68,5 +88,5 @@
             {
                 string data_zaplaty = String.Format("{0:dd-MM-yyyy}",tablica_potwierdzenia[0].AUTHTIME);
-                errorViewData.error = String.Format(HttpContext.GetGlobalResourceObject("tlumaczenia", "zaplacono").ToString(), platnosc.Faktura_Numer, data_zaplaty);
+                errorViewData.error = String.Format(zaplacono, platnosc.Faktura_Numer, data_zaplaty);
                 return View("Error1", errorViewData);
             }
@@ -83,5 +103,4 @@
         {
             language = _func.setLanguage(language);
-            string userName = ControllerContext.HttpContext.User.Identity.Name;
             int id1 = 0;
             try
@@ -94,12 +113,18 @@
             vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
             ErrorViewData errorViewData = new ErrorViewData();
+
+            if (!_func.UserIdentity(platnosc, userIdentity))
+            {
+                errorViewData.error = weryfikacja;
+                return View("Error1", errorViewData);
+            }
             if (platnosc == null)
             {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString();
-                return View("Error1", errorViewData);
-            }
-            else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name))
-            {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString();
+                errorViewData.error = brakdanych;
+                return View("Error1", errorViewData);
+            }
+            else if (!_func.UserIdentity(platnosc, userIdentity))
+            {
+                errorViewData.error = weryfikacja;
                 return View("Error1", errorViewData);  
             }
@@ -107,11 +132,9 @@
             if (String.IsNullOrEmpty(payer.FirstName))
             {
-                string err_imieWK = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_imieWK").ToString();
-                ModelState.AddModelError("Payer.FirstName", err_imieWK);
+                ModelState.AddModelError("Payer.FirstName", err_imie);
             }
             if (String.IsNullOrEmpty(payer.LastName))
             {
-                string err_nazwiskoWK = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_nazwiskoWK").ToString();
-                ModelState.AddModelError("Payer.LastName", err_nazwiskoWK);
+                ModelState.AddModelError("Payer.LastName", err_nazwisko);
             }
             if (ModelState.IsValid == false)
@@ -146,7 +169,7 @@
                 return View("Error1", errorViewData);
             }
-            else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name))
-            {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString();
+            else if (!_func.UserIdentity(platnosc, userIdentity))
+            {
+                errorViewData.error = weryfikacja;
                 return View("Error1", errorViewData);
             }
@@ -154,4 +177,15 @@
             return View(invoiceDeatailsViewData);
         }
+        public void UpdateStatus(int ordernumber, string validationcode)
+        {
+
+            var platnosc = _repPl.FindOne(i => i.ORDERNUMBER == ordernumber);
+            if (platnosc != null && platnosc.Status == true && validationcode == "000")
+            {
+                platnosc.Status = true;
+                platnosc.Status_data = DateTime.Now;
+                _repPl.Update(platnosc);
+            }
+        }
         public ActionResult Status()
         {
@@ -160,5 +194,4 @@
 
             //TODO: validate the Form
-
             string MERCHANTNUMBER = Request.Form["MERCHANTNUMBER"];
             int ORDERNUMBER = Convert.ToInt32(Request.Form["ORDERNUMBER"]);
@@ -214,4 +247,24 @@
             return invoiceDeatailsViewData;
         }
+        public void setUserIdentity(string value)
+        {
+            this.userIdentity = value;
+
+        }
+        public void setWeryfikacja(string value)
+        {
+            this.weryfikacja = value;
+
+        }
+        public void setBrakDanych(string value)
+        {
+            this.brakdanych = value;
+
+        }
+        public void setZaplacono(string value)
+        {
+            this.zaplacono = value;
+
+        }        
                
     }
