示例#1
0
        //Gmailden aktivasyon linkinden  buraya gelcez
        public ActionResult UserActivate(Guid id)
        {
            //Kullanıcı aktivasyonu sağlanacak
            EvernoteUserManager eum = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res = eum.ActivateUser(id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModel errorNotifyObj = new ErrorViewModel
                {
                    Title = "Geçersiz işlem",
                    Items = res.Errors
                };


                return(View("Error", errorNotifyObj)); //shareddaki viewi aç
            }


            OkViewModel okNotifyObj = new OkViewModel
            {
                Title          = @"Hesabınız aktifleştirildi",
                RedirectingUrl = "/Home/Login",//yönlendir.
            };

            okNotifyObj.Items.Add("Hesabınız aktifleştirildi.Artık not paylaşabilir ve beğenme yapabilirsiniz.");


            //aktifleştirme başarılı ise
            return(View("Ok", okNotifyObj));
        }
示例#2
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                EvernoteUserManager eum = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> res = eum.RegisterUser(model);
                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));

                    return(View(model));
                }

                OkViewModel notifyObj = new OkViewModel()
                {
                    Title          = "Kayıt Başarılı",
                    RedirectingUrl = "/Home/Login",
                };
                notifyObj.Items.Add("Lütfen e-posta adresinize gönderdiğimiz aktivasyon link'ine tıklayarak hesabınızı aktive ediniz.<br />Hesabınızı aktive etmeden not ekleyemez ve beğenme yapamazsınız");

                return(View("Ok", notifyObj));
            }

            return(View(model));
        }
示例#3
0
        public ActionResult UserActivate(Guid id)
        {
            //kullanıcı aktifleştirme
            EvernoteUserManager eum = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res = eum.ActivateUser(id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModel ErrornotifyObj = new ErrorViewModel()
                {
                    Title = "Geçersiz İşlem",
                    Items = res.Errors
                };


                return(View("Error", ErrornotifyObj));
            }

            OkViewModel oknotifyObj = new OkViewModel()
            {
                Title          = "Hesap Aktilştirildi",
                RedirectingUrl = "/Home/Login"
            };

            oknotifyObj.Items.Add("Hesabınız Aktifleştirildi. Artık not paylaşabilir ve beğenme yapabilirsiniz");

            return(RedirectToAction("Ok", oknotifyObj));
        }
示例#4
0
        public ActionResult EditProfile(EvernoteUser model, HttpPostedFileBase ProfileImage)
        {
            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.ProfileImageFilename = filename;
            }

            BusinessLayer.EvernoteUserManager  eum = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res = eum.UpdateProfile(model);

            if (res.Errors.Count > 0)
            {
                ErrorViewModel errorNotifyObj = new ErrorViewModel()
                {
                    Items          = res.Errors,
                    Title          = "Profil Güncellenemedi.",
                    RedirectingUrl = "/Home/EditProfile"
                };

                return(View("Error", errorNotifyObj));
            }

            Session["login"] = res.Result;

            return(RedirectToAction("ShowProfile"));
        }
示例#5
0
        public ActionResult Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                EvernoteUserManager eum = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> res = eum.LoginUser(model);

                if (res.Errors.Count > 0)
                {
                    if (res.Errors.Find(x => x.Code == ErrorMessageCode.UserIsNotActive) != null)
                    {
                        ViewBag.SetLink = "http://Home/Activate/1234-4567-78980";
                    }


                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));


                    return(View(model));
                }

                Session["login"] = res.Result; //session'a kullanıcı bilgisini saklama..
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
示例#6
0
        public ActionResult EditProfile()
        {
            EvernoteUser currentUser = CurrentSession.User;

            if (currentUser != null)
            {
                EvernoteUserManager eum = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> blr = eum.GetUserById(currentUser.Id);

                if (blr.Errors.Count > 0)
                {
                    ErrorViewModel errorModel = new ErrorViewModel();

                    blr.Errors.ForEach(x =>
                    {
                        errorModel.Items.Add(x.Value);
                    });

                    return(View("Error", errorModel));
                }
                else
                {
                    return(View(blr.Result));
                }
            }

            return(RedirectToAction("Login"));
        }
示例#7
0
        [Auth]  //filter ekledik.giriş yapmamışsa yönlendirme yapıyoruz bu classta(Filters klasöründe)(authenticationfilterlogin)
        public ActionResult ShowProfile()
        {
            //EvernoteUser currentUser = Session["login"] as EvernoteUser;

            BusinessLayer.EvernoteUserManager eum = new EvernoteUserManager();
            //BusinessLayerResult<EvernoteUser> res = eum.GetUserById(currentUser.Id);
            BusinessLayerResult <EvernoteUser> res = eum.GetUserById(CurrentSession.User.Id);

            //hata var demekki
            if (res.Errors.Count > 0)
            {
                //Kullanıcıyı bir hata ekranına yönlendirmemiz gerekiyor.
                ErrorViewModel errorNotifyObj = new ErrorViewModel
                {
                    Title = "Hata Oluştu",
                    Items = res.Errors
                };


                return(View("Error", errorNotifyObj)); //shareddaki viewi aç
            }


            return(View(res.Result));
        }
        public ActionResult EditProfile(EvernoteUser model, HttpPostedFileBase ProfileImage)
        {
            ModelState.Remove("ModifiedUsername");
            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.ProfileImageFilename = fileName;
                }

                evernoteUserManager = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> res = evernoteUserManager.UpdateProfile(model);

                if (res.Errors.Count > 0)
                {
                    ErrorViewModel errObj = new ErrorViewModel()
                    {
                        Title          = "Hata Oluştu",
                        Items          = res.Errors,
                        RedirectingUrl = "/Home/EditProfile"
                    };
                    return(View("Error", errObj));
                }
                CurrentSession.Set <EvernoteUser>("login", res.Result);

                return(RedirectToAction("ShowProfile"));
            }
            return(View(model));
        }
        public ActionResult Login(LoginViewModel model)
        {
            ViewBag.HataGoster = 1;
            if (ModelState.IsValid)
            {
                ViewBag.HataGoster = 0;
                EvernoteUserManager eum = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> res = eum.LoginUser(model);

                if (res.Errors.Count > 0)
                {
                    ViewBag.HataGoster = 1;

                    res.Errors.ForEach(x => ModelState.AddModelError("", x));

                    if (res.Errors.Contains("Kullanıcı aktifleştirilmemiştir. Lütfen e-posta hesabınıza gelen bağlantıyı doğrulayınız."))
                    {
                        ViewBag.SetLink = "http://akjshdkasdasd.com";
                    }

                    return(View(model));
                }

                Session["login"] = res.Result;
                return(RedirectToAction("Index", "Home"));
            }
            return(View(model));
        }
示例#10
0
        public ActionResult Login(LoginViewModel model)
        {
            EvernoteUserManager eum = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res = eum.LoginUser(model); // Giriş Kontrolü

            if (ModelState.IsValid)
            {
                if (res.Errors.Count > 0)
                {
                    //Hataları ModelState'e ekleme..

                    if (res.Errors.Find(x => x.Code == ErrorMessageCode.UserIsNotActive) != null)
                    {
                        ViewBag.SetLink = "http://Home/Activate/1234-4894-65489";
                    }
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));

                    return(View(model));
                }

                Session["login"] = res.Result;     // Session'a kullanıcı bilgisi saklama..
                return(RedirectToAction("Index")); // Giriş başarılıysa yönlendir.
            }

            return(View(model));
        }
示例#11
0
        [Auth]  //filter ekledik.giriş yapmamışsa yönlendirme yapıyoruz bu classta(Filters klasöründe)(authenticationfilterlogin)
        public ActionResult DeleteProfile()
        {
            EvernoteUser currentUser = Session["login"] as EvernoteUser;

            EvernoteUserManager eum = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res =
                eum.RemoveUserById(currentUser.Id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModel errorNotifyObj = new ErrorViewModel()
                {
                    Items          = res.Errors,
                    Title          = "Profil Silinemedi.",
                    RedirectingUrl = "/Home/ShowProfile" //yönlendir.
                };

                return(View("Error", errorNotifyObj));
            }

            //sessionı sil.
            Session.Clear();

            return(RedirectToAction("Index"));
        }
示例#12
0
        public ActionResult UserActivate(Guid id)
        {
            EvernoteUserManager eum = new EvernoteUserManager();
            BusinessLayerResult <EverNoteUser> res = eum.ActivateUser(id);

            if (res.Errors.Count > 0)
            {
                TempData["errors"] = res.Errors;
                return(RedirectToAction("UserActivateCancel"));
            }
            return(RedirectToAction("UserActivateOk"));
        }
示例#13
0
        public ActionResult Register(RegisterViewModel model)
        {
            EvernoteUserManager eum = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res = eum.RegisterUser(model);

            if (res.Errors.Count > 0)
            {
                res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                return(View(model));
            }

            return(RedirectToAction("RegisterOk"));
        }
示例#14
0
        public ActionResult EditProfile(EvernoteUser model, HttpPostedFileBase ProfileImage)
        {
            ModelState.Remove("ModifiedUsername");

            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.ProfileImageFile = filename;
                }

                EvernoteUserManager eum = new EvernoteUserManager();

                BusinessLayerResult <EvernoteUser> res = eum.UpdateProfile(model);

                if (res.Errors.Count > 0)
                {
                    // Kullanıcıyı Hata Ekranına Yönlendiricez

                    ErrorViewModel errorNotifyObj = new ErrorViewModel()
                    {
                        Title       = "Profil Güncellenemedi",
                        Items       = res.Errors,
                        RedirectUrl = "/Home/EditProfile"
                    };

                    return(View("Error", errorNotifyObj));
                }

                CurrentSession.Set <EvernoteUser>("login", res.Result); // Profil Güncellendigi icin session güncellendi.

                return(RedirectToAction("ShowProfile"));
            }

            else
            {
                return(View(model));
            }
        }
示例#15
0
        public ActionResult EditProfile(EvernoteUser model, HttpPostedFileBase ProfileImage) //   <input type="file" name="ProfileImage" id="ProfileImage" class="form-control" /><br /> name ler aynı olmalı
        {
            //Html validation summaryde bu hata gözükmez.
            ModelState.Remove("ModifiedUsername");

            if (ModelState.IsValid)//model hatalı geldiyse Isvalid=false olur.
            {
                //resmi kaydediyoruz.

                //dosya tipi
                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));//belirtilen yola resmi kaydediyoruz.
                    model.ProfileImageFileName = filename;
                }

                EvernoteUserManager evernoteUserManager = new EvernoteUserManager();

                BusinessLayerResult <EvernoteUser> res = evernoteUserManager.UpdateProfile(model);

                if (res.Errors.Count > 0)
                {
                    ErrorViewModel errorNotifyObj = new ErrorViewModel()
                    {
                        Items          = res.Errors,
                        Title          = "Profil Güncellenemedi.",
                        RedirectingUrl = "/Home/EditProfile"
                    };

                    return(View("Error", errorNotifyObj));
                }

                // Profil güncellendiği için session güncellendi.

                CurrentSession.Set <EvernoteUser>("login", res.Result);
                //Session["login"] = res.Result;

                return(RedirectToAction("ShowProfile"));
            }

            return(View(model));
        }
        public ActionResult EditProfile()
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            EvernoteUser        currentUser        = Session["login"] as EvernoteUser;
            EvernoteUserManager eum                = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res = eum.GetUserById(currentUser.Id);

            if (res.Errors.Count > 0)
            {
                //hata
            }


            return(View(res.Result));
        }
示例#17
0
        public ActionResult EditProfile()
        {
            EvernoteUserManager evernoteUserManager = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res  = evernoteUserManager.GetUserById(CurrentSession.User.Id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModel errorNotifyObj = new ErrorViewModel()
                {
                    Title = "Hata Oluştu",
                    Items = res.Errors
                };
                TempData["errors"] = res.Errors;
                return(View("Error", errorNotifyObj));
            }

            return(View(res.Result));
        }
示例#18
0
        public ActionResult Register(RegisterViewModel model)
        { // kullanıcı username kontrolü
          // kullanıcı eposta kontrolü
          //kullanıcı kaydı
          //Aktivasyon eposta göstergesi
            if (ModelState.IsValid)
            {
                EvernoteUserManager eum = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> res = eum.RegisterUser(model);
                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); //burda amaç hangi hata mesajı verdiysek ona göre bir string atamak istersek yani avtive etme linki yada şifremi unuttum gibi hata messajına id eklemiş olduk
                    return(View(model));
                }

                //EvernoteUser user = null;
                //try
                //{
                //   user= eum.RegisterUser(model);
                //}
                //catch (Exception ex)
                //{


                //    ModelState.AddModelError("", ex.Message);
                //}
                //if(user==null)
                //{
                //    return View(model);
                //}

                OkViewModel notifyObj = new OkViewModel()
                {
                    Title          = "Kayıt Başarılı",
                    RedirectingUrl = "/Home/Login",
                };

                notifyObj.Items.Add("Lütfen e-posta adresinize gönderdiğimiz aktivasyon link'ine tıklayarak hesabınızı aktive ediniz. Hesabınızı aktive etmeden not ekleyemez ve beğenme yapamazsınız.");

                return(View("Ok", notifyObj));
            }

            return(View(model));
        }
示例#19
0
        public ActionResult ShowProfile()
        {
            EvernoteUser        currentUser        = Session["login"] as EvernoteUser;
            EvernoteUserManager eum                = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> res = eum.GetUserById(currentUser.Id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModel errorNotifyObj = new ErrorViewModel()
                {
                    Title = "Hata Oluştu",
                    Items = res.Errors
                };

                return(View("Error", errorNotifyObj));
            }

            return(View(res.Result));
        }
示例#20
0
        public ActionResult UserActivate(Guid activateID)
        {
            EvernoteUserManager eum = new EvernoteUserManager();
            BusinessLayerResult <EvernoteUser> blr = eum.ActivateUser(activateID);

            if (blr.Result != null)
            {
                if (blr.Informations.Count > 0)
                {
                    InfoViewModel model = new InfoViewModel();

                    blr.Informations.ForEach(x =>
                    {
                        model.Items.Add(x.Value);
                    });

                    return(View("Info", model));
                }
                else
                {
                    OkViewModel model = new OkViewModel();

                    model.Items.Add("Hesap aktivasyon işleminiz başarılı bir şekilde gerçekleştirilmiştir.");

                    return(View("Ok", model));
                }
            }
            else
            {
                ErrorViewModel model = new ErrorViewModel();

                blr.Errors.ForEach(x =>
                {
                    model.Items.Add(x.Value);
                });

                return(View("Error", model));
            }
        }
示例#21
0
        public ActionResult Login(LoginViewModel model)
        {
            //Giriş kontrolü ve yönlendirme yapılacak
            //Session'a kullanıcı bilgi saklama



            if (ModelState.IsValid)    //model doğru gelmişse
            {
                EvernoteUserManager eum = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> res = eum.LoginUser(model);


                //demekki hata var
                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));//ilgili hatayı metoda ekle dedik.foreach ile .bu hatayıda view tarafında Validation summary ile okuyor.

                    //business layerdan dönen hataların yönetimi
                    if (res.Errors.Find(x => x.Code == ErrorMessageCode.UserIsNotActive) != null)
                    {
                        ViewBag.SetLink = "http://Home/Activate/1313-4344345-345345";
                    }



                    return(View(model));
                }

                //giriş başarılı ise
                Session["login"] = res.Result;     //sessiona kullanıcı bilgisini at

                return(RedirectToAction("Index")); //yönlendirme ..
            }



            return(View(model));
        }
示例#22
0
 public ActionResult Login(LoginViewModel model)
 {
     if (ModelState.IsValid)
     {
         EvernoteUserManager eum = new EvernoteUserManager();
         BusinessLayerResult <EvernoteUser> res = eum.LoginUser(model);
         if (res.Errors.Count > 0)
         {
             res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));//176.derste bu koda ek olarak kullanıcıa hesap aktive ettirmek için link verdik daha sonra yapacağım
             if (res.Errors.Find(x => x.Code == ErrorMessageCode.UserIsNotActive) != null)
             {
                 ViewBag.SetLink = "https://www.google.com.tr/";
             }
             return(View(model));
         }
         else
         {
             Session["login"] = res.Result;     //session ile kullanıcı tutma
             return(RedirectToAction("Index")); //yönlendirme
         }
     }
     return(View(model));
 }
        public ActionResult EditProfile(EvernoteUser user, HttpPostedFileBase profileImage)
        {
            ModelState.Remove("ModifiedUserName");
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");

            if (ModelState.IsValid)
            {
                if (profileImage != null && (profileImage.ContentType == "image/jpeg" ||
                                             profileImage.ContentType == "image/jpg" ||
                                             profileImage.ContentType == "image/png"))
                {
                    string fileName = $"user_{user.Id}_profileImage.{profileImage.ContentType.Split('/')[1]}";
                    //string dosyaYolu = Server.MapPath("~/images/");

                    //if (dosyaYolu.Contains(fileName))
                    //{

                    //}
                    profileImage.SaveAs(Server.MapPath($"~/images/{fileName}"));
                    user.ProfileImageFile = fileName;
                }


                EvernoteUserManager eum = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> res = eum.UpdateProfile(user);

                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x));
                    return(View(res.Result));
                }

                Session["login"] = res.Result;
            }
            return(View(user));
        }
示例#24
0
        public ActionResult Register(RegisterViewModel model)
        {
            //Kullanıcı username kontrolü
            //Kullanıcı eposta kontrolü..
            //Kayıt İşlemi..
            // Aktivasyon epostası gönderimi

            if (ModelState.IsValid) //model RegisterViewModel modelindeki data annotation daki kurallara uyuyorsa
            {
                EvernoteUserManager eum = new EvernoteUserManager();
                BusinessLayerResult <EvernoteUser> res = eum.RegisterUser(model);


                //demekki hata var
                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));//ilgili hatayı metoda ekle dedik.foreach ile .bu hatayıda view tarafında Validation summary ile okuyor.

                    return(View(model));
                }



                #region Yorumsatırları
                //EvernoteUser user = null;
                //try
                //{

                //    user = eum.RegisterUser(model);
                //}
                //catch (Exception ex)
                //{
                //    ModelState.AddModelError("", ex.Message);

                //}



                //if (model.UserName == "aaa")
                //{
                //    ModelState.AddModelError("", "Kullanıcı adı kullanılıyor");//kendimiz hata mesajı veriyoruz.ValidationSummaryde gözükecek

                //}



                //if (model.EMail == "*****@*****.**")
                //{
                //    ModelState.AddModelError("", "Eposta adresi kullanılıyor");

                //}



                //foreach (var item in ModelState)
                //{
                //    if (item.Value.Errors.Count > 0)
                //    {
                //        return View(model);
                //    }
                //}

                //demekki hata var
                //if (user == null)
                //{
                //    return View(model);
                //}
                #endregion


                //kayıt başarılı olunca yönlendir.
                OkViewModel notifyObj = new OkViewModel
                {
                    Title          = @"Kayıt Başarılı",
                    RedirectingUrl = "/Home/Login",
                };
                notifyObj.Items.Add(@"Lütfen eposta adresinize gönderdiğimiz aktivasyon linkine tıklayarak hesabınızı aktive ediniz.
Hesabınızı aktive etmeden not ekleyemez ve beğenme yapamazsınız,");



                return(View("Ok", notifyObj));
            }



            return(View(model));
        }