public ActionResult Edit(Ucet ucet) { ucet.RoleUzivatele = new RoleDao().GetById(ucet.RoleUzivatele.Id); if (ModelState.IsValidField("Jmeno") && ModelState.IsValidField("Prijmeni") && ModelState.IsValidField("Prezdivka") && ModelState.IsValidField("Adresa.Mesto") && ModelState.IsValidField("Email") && ModelState.IsValidField("Telefon") && ModelState.IsValidField("Adresa.PSC") && ModelState.IsValidField("Adresa.UliceCP") && ModelState.IsValidField("Adresa.Zeme") && ModelState.IsValidField("Heslo") && ModelState.IsValidField("Login")) { UcetDao ucetDao = new UcetDao(); AdresaDao adresaDao = new AdresaDao(); MD5 md5 = new MD5CryptoServiceProvider(); Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(ucet.Heslo); Byte[] encodedBytes = md5.ComputeHash(originalBytes); String newpassword = BitConverter.ToString(encodedBytes); ucet.Heslo = newpassword; ucetDao.Update(ucet); adresaDao.Update(ucet.Adresa); TempData["zprava"] = "Editace byla provedena"; return(RedirectToAction("DetailUctu")); } else { TempData["zprava"] = "Editace nebyla provedena. Něco se pokazilo."; return(RedirectToAction("DetailUctu")); } //return Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()); }
public ActionResult aktivace(int?_page, int?_itemsOnPage, bool?vse, int?showRole, string _id) { int id = int.Parse(_id); UcetDao ucetdao = new UcetDao(); Ucet ucet = ucetdao.GetById(id); if (ucet.Aktivovano) { ucet.Aktivovano = false; } else { ucet.Aktivovano = true; } ucetdao.Update(ucet); return(RedirectToAction("Uzivatele", new { _page = _page, vse = vse, _itemsOnPage = _itemsOnPage, showRole = showRole })); }
public ActionResult aktivace2(string _id) { int id = int.Parse(_id); UcetDao ucetdao = new UcetDao(); Ucet ucet = ucetdao.GetById(id); if (ucet.Aktivovano) { ucet.Aktivovano = false; } else { ucet.Aktivovano = true; } ucetdao.Update(ucet); return(RedirectToAction("DetailUzivatele", new { id = id })); }
public ActionResult zmenaHesla(string pasOld, string pasNew, string pasNewNew) { UcetDao ucetDao = new UcetDao(); MD5 md5 = new MD5CryptoServiceProvider(); Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(pasOld); Byte[] encodedBytes = md5.ComputeHash(originalBytes); pasOld = BitConverter.ToString(encodedBytes); if (pasNew == pasNewNew) { try { Ucet ucet = ucetDao.GetByLoginAndPassword(User.Identity.Name, pasOld); if (ucet.Heslo == pasOld) { md5 = new MD5CryptoServiceProvider(); originalBytes = ASCIIEncoding.Default.GetBytes(pasNew); encodedBytes = md5.ComputeHash(originalBytes); String newpassword = BitConverter.ToString(encodedBytes); ucet.Heslo = newpassword; ucetDao.Update(ucet); TempData["zprava"] = "Změna hesla byla provedena."; return(RedirectToAction("DetailUctu")); } } catch (Exception e) { TempData["zprava"] = "Staré heslo nesouhlasí"; return(RedirectToAction("DetailUctu")); } } TempData["zprava"] = "Změna hesla nebyla provede. Nové heslo a potvrzení nového hesla není stejné"; return(RedirectToAction("DetailUctu")); }