public ActionResult DeleteProfil() { Kullanici kullanici = Session["login"] as Kullanici; KullaniciYönetimi KY = new KullaniciYönetimi(); kullanici = KY.DeleteByKullaniciId(kullanici.KullaniciID); Session.Clear(); return(RedirectToAction("Index")); }
public ActionResult EditProfil() { Kullanici kayitliKullanici = Session["login"] as Kullanici; KullaniciYönetimi KY = new KullaniciYönetimi(); try { Kullanici kul = KY.GetKullaniciById(kayitliKullanici.KullaniciID); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } return(View(kayitliKullanici)); }
public ActionResult EditProfil(Kullanici model, HttpPostedFileBase ProfilFoto) { if (ModelState.IsValid) { if (ProfilFoto != null && (ProfilFoto.ContentType == "image/jpeg" || ProfilFoto.ContentType == "image/jpg" || ProfilFoto.ContentType == "image/png")) { Random rnd = new Random(); string dosyaAdi = $"Kullanıcı_{rnd.Next(1,10)}.{ProfilFoto.ContentType.Split('/')[1]}"; ProfilFoto.SaveAs(Server.MapPath($"~/Images/{dosyaAdi}")); model.ProfilFotoDosyaAdi = dosyaAdi; } KullaniciYönetimi KY = new KullaniciYönetimi(); try { Kullanici klnc = KY.ProfilGuncelleme(model); Session["login"] = klnc; // Profil güncelledik session güncellendi. } catch (Exception ex) { int sonuc; ModelState.AddModelError("", ex.Message); sonuc = string.Compare("telefon", ex.Message); if (sonuc == -1) { return(RedirectToAction("KayitliTelefon", "Hata")); } sonuc = string.Compare("E-posta", ex.Message); if (sonuc == -1) { return(RedirectToAction("KayitliEmail", "Hata")); } } return(RedirectToAction("Profil")); } return(View(model)); }
public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid) { KullaniciYönetimi ky = new KullaniciYönetimi(); Kullanici kullanici = null; try { kullanici = ky.KullaniciKayit(model); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } if (kullanici == null) { return(View(model)); } return(RedirectToAction("RegisterOk", "Home")); } return(View(model)); }
public ActionResult Login(LoginViewModel model) { if (ModelState.IsValid) { KullaniciYönetimi ky = new KullaniciYönetimi(); Kullanici kullanici = null; try { kullanici = ky.KullaniciGiris(model); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } if (kullanici != null) { Session["login"] = kullanici; return(RedirectToAction("Index", "Home")); } return(View(model)); } return(View(model)); }