Pokaż
Ignoruj:
Data:
2009-11-09 16:00:17 (16 years ago)
Autor:
alina
Opis:

re #215

Pliki:
1 zmodyfikowane

Legenda:

Bez zmian
Dodane
Usunięte
  • trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs

    r870 r871  
    2323        private readonly IDataContext _context1; 
    2424        private readonly IRepository<PotwierdzeniaEcard> _rep; 
    25         private readonly IRep<PotwierdzeniaEcard> _repository; 
     25        private readonly IRepository<PlatnosciEcard> _repPl; 
    2626        private FunkcjePlatnosci _func; 
    27  
     27        private string userIdentity = ""; 
     28        private string weryfikacja = ""; 
     29        private string brakdanych = ""; 
     30        private string zaplacono = ""; 
     31        private string err_imie = ""; 
     32        private string err_nazwisko = ""; 
     33         
     34 
     35        protected override void Initialize(System.Web.Routing.RequestContext requestContext) 
     36        {             
     37            base.Initialize(requestContext); 
     38            userIdentity = HttpContext.User.Identity.Name; 
     39            weryfikacja = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString(); 
     40            brakdanych = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString(); 
     41            zaplacono = HttpContext.GetGlobalResourceObject("tlumaczenia", "zaplacono").ToString(); 
     42            err_imie = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_imieWK").ToString(); 
     43            err_nazwisko = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_nazwiskoWK").ToString();            
     44        }        
    2845 
    2946        public PlatnoscController() 
    3047        { 
    3148            _context = new PlatnosciDataContext(); 
    32             _rep = new Repository<PotwierdzeniaEcard>(new DataContext1());  
     49            _rep = new Repository<PotwierdzeniaEcard>(new DataContext1()); 
     50            _repPl = new Repository<PlatnosciEcard>(new DataContext1()); 
    3351            _func = new FunkcjePlatnosci(); 
     52                       
    3453        } 
    3554        public PlatnoscController(IDataContext datacontext){ 
    3655            _rep = new Repository<PotwierdzeniaEcard>(datacontext); 
     56            _repPl = new Repository<PlatnosciEcard>(datacontext); 
    3757            _context1 = datacontext; 
     58            _func = new FunkcjePlatnosci();             
    3859        } 
    3960        public ActionResult Show(string id, string language) 
     
    4970            { 
    5071            } 
    51             
     72           
    5273            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 
    53             //sprawdzamy czy numer faktury dotyczy zalogowanego usera 
    5474            ErrorViewData errorViewData = new ErrorViewData(); 
    5575            if (platnosc == null) 
    5676            { 
    57                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString(); 
     77               errorViewData.error = brakdanych; 
    5878               return View("Error1", errorViewData);                 
    5979            } 
    60             else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name)) 
    61             { 
    62                 errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString(); 
     80            else if (!_func.UserIdentity(platnosc, userIdentity)) 
     81            { 
     82                errorViewData.error = weryfikacja; 
    6383                return View("Error1", errorViewData); 
    6484            } 
     
    6888            { 
    6989                string data_zaplaty = String.Format("{0:dd-MM-yyyy}",tablica_potwierdzenia[0].AUTHTIME); 
    70                 errorViewData.error = String.Format(HttpContext.GetGlobalResourceObject("tlumaczenia", "zaplacono").ToString(), platnosc.Faktura_Numer, data_zaplaty); 
     90                errorViewData.error = String.Format(zaplacono, platnosc.Faktura_Numer, data_zaplaty); 
    7191                return View("Error1", errorViewData); 
    7292            } 
     
    83103        { 
    84104            language = _func.setLanguage(language); 
    85             string userName = ControllerContext.HttpContext.User.Identity.Name; 
    86105            int id1 = 0; 
    87106            try 
     
    94113            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault(); 
    95114            ErrorViewData errorViewData = new ErrorViewData(); 
     115 
     116            if (!_func.UserIdentity(platnosc, userIdentity)) 
     117            { 
     118                errorViewData.error = weryfikacja; 
     119                return View("Error1", errorViewData); 
     120            } 
    96121            if (platnosc == null) 
    97122            { 
    98                 errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString(); 
    99                 return View("Error1", errorViewData); 
    100             } 
    101             else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name)) 
    102             { 
    103                 errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString(); 
     123                errorViewData.error = brakdanych; 
     124                return View("Error1", errorViewData); 
     125            } 
     126            else if (!_func.UserIdentity(platnosc, userIdentity)) 
     127            { 
     128                errorViewData.error = weryfikacja; 
    104129                return View("Error1", errorViewData);   
    105130            } 
     
    107132            if (String.IsNullOrEmpty(payer.FirstName)) 
    108133            { 
    109                 string err_imieWK = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_imieWK").ToString(); 
    110                 ModelState.AddModelError("Payer.FirstName", err_imieWK); 
     134                ModelState.AddModelError("Payer.FirstName", err_imie); 
    111135            } 
    112136            if (String.IsNullOrEmpty(payer.LastName)) 
    113137            { 
    114                 string err_nazwiskoWK = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_nazwiskoWK").ToString(); 
    115                 ModelState.AddModelError("Payer.LastName", err_nazwiskoWK); 
     138                ModelState.AddModelError("Payer.LastName", err_nazwisko); 
    116139            } 
    117140            if (ModelState.IsValid == false) 
     
    146169                return View("Error1", errorViewData); 
    147170            } 
    148             else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name)) 
    149             { 
    150                 errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString(); 
     171            else if (!_func.UserIdentity(platnosc, userIdentity)) 
     172            { 
     173                errorViewData.error = weryfikacja; 
    151174                return View("Error1", errorViewData); 
    152175            } 
     
    154177            return View(invoiceDeatailsViewData); 
    155178        } 
     179        public void UpdateStatus(int ordernumber, string validationcode) 
     180        { 
     181 
     182            var platnosc = _repPl.FindOne(i => i.ORDERNUMBER == ordernumber); 
     183            if (platnosc != null && platnosc.Status == true && validationcode == "000") 
     184            { 
     185                platnosc.Status = true; 
     186                platnosc.Status_data = DateTime.Now; 
     187                _repPl.Update(platnosc); 
     188            } 
     189        } 
    156190        public ActionResult Status() 
    157191        { 
     
    160194 
    161195            //TODO: validate the Form 
    162  
    163196            string MERCHANTNUMBER = Request.Form["MERCHANTNUMBER"]; 
    164197            int ORDERNUMBER = Convert.ToInt32(Request.Form["ORDERNUMBER"]); 
     
    214247            return invoiceDeatailsViewData; 
    215248        } 
     249        public void setUserIdentity(string value) 
     250        { 
     251            this.userIdentity = value; 
     252 
     253        } 
     254        public void setWeryfikacja(string value) 
     255        { 
     256            this.weryfikacja = value; 
     257 
     258        } 
     259        public void setBrakDanych(string value) 
     260        { 
     261            this.brakdanych = value; 
     262 
     263        } 
     264        public void setZaplacono(string value) 
     265        { 
     266            this.zaplacono = value; 
     267 
     268        }         
    216269                
    217270    }