public ActionResult UserActivate(Guid id) { //Kullanıcı aktivasyonu sağlanacak KeepITUserManager kum = new KeepITUserManager(); BusinessLayerResult <KeepITUser> res = kum.ActivateUser(id); if (res.Errors.Count > 0) { ErrorViewModel errorNotify = new ErrorViewModel() { Title = "Geçersiz İşlem", Items = res.Errors }; return(View("Error", errorNotify)); } OkViewModel okNotify = new OkViewModel() { Title = "Hesap Aktifleştirildi.", RedirectingUrl = "/Home/Login" }; okNotify.Items.Add("Hesabınız aktifleştirildi. Artık Not paylaşabilirsiniz."); return(View("Ok", okNotify)); }
public ActionResult Register(RegisterViewModel model) { // User ve Eposta kontrolü // Kayıt işlemi... // Aktivasyon epostası gönderimi if (ModelState.IsValid) { KeepITUserManager eum = new KeepITUserManager(); BusinessLayerResult <KeepITUser> res = eum.RegisterUser(model); if (res.Errors.Count > 0) { res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); // Tüm error listesinde foreachle dön her biri için ilgili stringi model errora ekle return(View(model)); } OkViewModel notify = new OkViewModel() { Title = "Kayıt Başarılı", RedirectingUrl = "/Home/Login" }; notify.Items.Add("Lütfen e-posta adresinize gönderilen aktivasyon linkine tıklayarak hesabınızı aktif ediniz."); return(View("Ok", notify)); } return(View(model)); }
public ActionResult Login(LoginViewModel model) { //Giriş Kontrolü if (ModelState.IsValid) { KeepITUserManager kum = new KeepITUserManager(); BusinessLayerResult <KeepITUser> res = kum.LoginUser(model); if (res.Errors.Count > 0) { if (res.Errors.Find(x => x.Code == ErrorMessageCodes.UserIsNotActive) != null) { ViewBag.SetLink = "E-Posta Gönder"; } res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); // Tüm error listesinde foreachle dön her biri için ilgili stringi model errora ekle return(View(model)); } Session["login"] = res.Result; // Session'a kullanıcı bilgisi saklama return(RedirectToAction("Index")); // yönlendirme } return(View(model)); }
public ActionResult EditProfile(KeepITUser model, HttpPostedFileBase ProfileImage) { if (ModelState.IsValid) { if (ProfileImage != null && (ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png")) { string filename = $"user_{model.Id}.{ProfileImage.ContentType.Split('/')[1]}"; ProfileImage.SaveAs(Server.MapPath($"~/images/{filename}")); model.ProfilePhotoPath = filename; } KeepITUserManager kum = new KeepITUserManager(); BusinessLayerResult <KeepITUser> res = kum.UpdateProfile(model); if (res.Errors.Count > 0) { ErrorViewModel errorNotify = new ErrorViewModel() { Items = res.Errors, Title = "Profil Güncellenemedi.", RedirectingUrl = "/Home/EditProfile", RedirectingTimeout = 5000 }; return(View("Error", errorNotify)); } // Profil güncellendiği için session güncellendi. Session["login"] = res.Result; return(RedirectToAction("ShowProfile")); } return(View(model)); }
public ActionResult EditProfile() { KeepITUser currentUser = Session["login"] as KeepITUser; KeepITUserManager kum = new KeepITUserManager(); BusinessLayerResult <KeepITUser> res = kum.GetUserById(currentUser.Id); if (res.Errors.Count > 0) { ErrorViewModel errorNotify = new ErrorViewModel() { Title = "Bir Hata Oluştu.", Items = res.Errors }; return(View("Error", errorNotify)); } return(View(res.Result)); }
public ActionResult DeleteProfile() { KeepITUser currentUser = Session["login"] as KeepITUser; KeepITUserManager kum = new KeepITUserManager(); BusinessLayerResult <KeepITUser> res = kum.RemoveUserById(currentUser.Id); if (res.Errors.Count > 0) { ErrorViewModel errorNotifyObj = new ErrorViewModel() { Items = res.Errors, Title = "Profil Silinemedi.", RedirectingUrl = "/Home/ShowProfile", RedirectingTimeout = 5000 }; return(View("Error", errorNotifyObj)); } Session.Clear(); return(RedirectToAction("Index")); }