public IActionResult Update(Kunder K) { var Session = new SessionData(_httpContextAccessor); var UserID = Session.GetSessionKundId(); var Validate = new RegisterValidation(); if (_Connection.GetKund(UserID).AnvandarNamn != K.Kund.AnvandarNamn) { if (!Validate.ValidateRegister(K, _Connection.GetAllKunder().ToList())) { ModelState.AddModelError("Kund.AnvandarNamn", "Användarnamn taget"); return(View(K)); } } if (ModelState.IsValid) { _Connection.UpdateKund(K, Session.GetSessionKund()); var LoginValidation = new LoginValidation(_Connection, _httpContextAccessor); LoginValidation.CheckLogin(K); return(RedirectToAction("Index", "Home")); } else { return(View(K)); } }
public IActionResult Login(Kunder K) { var Validate = new LoginValidation(_Connection, _httpContextAccessor); var Kunder = _Connection.GetAllKunder(); if (Validate.ValidateLogin(K, Kunder) && Validate.ValidatePassword(K, Kunder)) { Validate.CheckLogin(K); return(RedirectToAction("Index", "Home")); } else { if (!Validate.ValidateLogin(K, Kunder)) { ModelState.AddModelError("Kund.Anvandarnamn", "Fel Användarnamn"); } if (!Validate.ValidatePassword(K, Kunder)) { ModelState.AddModelError("Kund.Losenord", "Fel Lösenord"); } return(View(K)); } }