public BusinesLayerResult <EvernoteUser> LoginUser(LoginViewModel data)
        {
            /* Yapılacak işlemler aşağıdaki gibidir.
             * 1-  Giriş kontrolü
             * 2-  Hesap aktive edilmiş mi? */


            BusinesLayerResult <EvernoteUser> res = new BusinesLayerResult <EvernoteUser>();

            res.Result = Find(x => x.Username == data.Username && x.Password == data.Password);

            if (res.Result != null)
            {
                if (!res.Result.IsActive)
                {
                    res.AddError(ErrorMessageCode.UserIsNotActive, "Kullanıcı aktifleştirilmemiştir.");
                    res.AddError(ErrorMessageCode.CheckYourEmail, "Lütfen e-posta adresini kontrol ediniz.");
                }
            }
            else
            {
                res.AddError(ErrorMessageCode.UsernameOrPassWrong, "Kullanıcı adı ya da şifre uyuşmuyor");
            }

            return(res);
        }
        //metot gizleme new ile olur.
        public new BusinesLayerResult <EvernoteUser> Insert(EvernoteUser data)
        {
            EvernoteUser user = Find(x => x.Username == data.Username || x.Email == data.Email);
            BusinesLayerResult <EvernoteUser> res = new BusinesLayerResult <EvernoteUser>();

            res.Result = data;

            if (user != null)
            {
                if (user.Username == data.Username)
                {
                    res.AddError(ErrorMessageCode.UsernameAllreadyExists, "Kullanıcı adı kayıtlı.");
                }

                if (user.Email == data.Email)
                {
                    res.AddError(ErrorMessageCode.EmailAllreadyExists, "E-posta adresi kayıtlı.");
                }
            }

            else
            {
                res.Result.ProfileImageFileName = "images.jpg";
                res.Result.ActivateGuid         = Guid.NewGuid();
                if (base.Insert(res.Result) == 0)
                {
                    res.AddError(ErrorMessageCode.UserCouldNotInserted, "Kullanıcı eklenemedi.");
                }
            }

            return(res);
        }
        public ActionResult Odeme(KartModelViews model)
        {
            if (ModelState.IsValid)
            {
                BusinesLayerResult <Kart> kart = km.CartUser(model);
                if (kart.Errors.Count > 0)
                {
                    kart.Errors.ForEach(x => ModelState.AddModelError("", x));
                    return(View(model));
                }
                Session["login"] = kart.Result;
                //return RedirectToAction("RegisterOk");
                OkViewModel notifyObj = new OkViewModel()
                {
                    Title          = "Odeme Başarılı",
                    RedirectingUrl = "/Randevu/Index",
                };

                notifyObj.Items.Add("Lütfen e-posta adresinize gönderdiğimiz aktivasyon link'ine tıklayarak odemeyi onaylayınız.");

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

            return(View(model));
        }
        public ActionResult ShowProfil()
        {
            User currentUser = Session["login"] as User;

            BusinesLayerResult <User> res = um.GetUserById(currentUser.Id);

            if (res.Errors.Count > 0)
            {
            }
            return(View(res.Result));
        }
        public BusinesLayerResult <EvernoteUser> GetUserById(int id)
        {
            BusinesLayerResult <EvernoteUser> res = new BusinesLayerResult <EvernoteUser>();

            res.Result = Find(x => x.Id == id);

            if (res.Result == null)
            {
                res.AddError(ErrorMessageCode.UserNotFound, "Kullanıcı bulunamadı.");
            }

            return(res);
        }
        public BusinesLayerResult <EvernoteUser> RegisterUser(RegisterViewModel data)
        {
            /*Yapılacak işlemler aşağıdaki gibidir.
             * 1-  Kullanıcı user kontrolü
             * 2-  Kullanıcı eposta kontrolü
             * 3-  Kayıt işlemi
             * 4-  Aktivasyon e-postası gönderimi.*/

            EvernoteUser user = Find(x => x.Username == data.Username || x.Email == data.Email);
            BusinesLayerResult <EvernoteUser> res = new BusinesLayerResult <EvernoteUser>();

            if (user != null)
            {
                if (user.Username == data.Username)
                {
                    res.AddError(ErrorMessageCode.UsernameAllreadyExists, "Kullanıcı adı kayıtlı.");
                }

                if (user.Email == data.Email)
                {
                    res.AddError(ErrorMessageCode.EmailAllreadyExists, "E-posta adresi kayıtlı.");
                }
            }

            else
            {
                int dbResult = base.Insert(new EvernoteUser()

                {
                    Username             = data.Username,
                    Email                = data.Email,
                    ProfileImageFileName = "images.jpg",
                    Password             = data.Password,
                    ActivateGuid         = Guid.NewGuid(),
                    IsActive             = false,
                    IsAdmin              = false
                });

                if (dbResult > 0)
                {
                    res.Result = Find(x => x.Email == data.Email && x.Username == data.Username);
                    string siteUri     = ConfigHelper.Get <string>("SiteRootUri");
                    string activateUri = $"{siteUri}/Home/UserActivate/{res.Result.ActivateGuid}";
                    string body        = $"Merhaba {res.Result.Username};<br><br>Hesabınızı aktifleştirmek için <a href='{activateUri}' target='_blank'>tıklayınız</a>.";
                    MailHelper.SendMail(body, res.Result.Email, "MyEvernote Hesap Aktifleştirme");
                }
            }

            return(res);
        }
 public ActionResult Login(UserLoginModel model)
 {
     if (ModelState.IsValid)
     {
         BusinesLayerResult <User> res = um.LoginUser(model);
         if (res.Errors.Count > 0)
         {
             res.Errors.ForEach(x => ModelState.AddModelError("", x));
             return(View(model));
         }
         //odemeye basıldığında basarılı bir şekilde ödeme yapıldı ve onaylı olmayan randevu onaylansın
         Session["login"] = res.Result;
         return(RedirectToAction("Anasayfam"));
     }
     return(View(model));
 }
 public ActionResult Index(User data)
 {
     if (data.Mail != null)
     {
         //Giriş İşlemi Yap
         Maneger mng = new Maneger();
         BusinesLayerResult <User> res = mng.Login(data.Mail, data.Sifre);
         if (res.Errors.Count > 0)
         {
             res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
             return(View(data));
         }
         Session["login"] = res.result;
         return(RedirectToAction("Index", "Home"));
     }
     return(View());
 }
Beispiel #9
0
        public ActionResult Edit(EvernoteUser evernoteUser)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUsername");
            if (ModelState.IsValid)
            {
                BusinesLayerResult <EvernoteUser> res = evernoteUserMenager.Update(evernoteUser);

                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                    return(View(evernoteUser));
                }
                return(RedirectToAction("Index"));
            }
            return(View(evernoteUser));
        }
Beispiel #10
0
        public ActionResult EditProfile()
        {
            BusinesLayerResult <EvernoteUser> res = evernoteUserMenager.GetUserById(CurrentSession.User.Id);

            if (res.Errors.Count > 0)
            {
                //kullanıcıyı hata ekranına yönlendirmemiz gerekiyor.

                ErrorViewModel errornotifyObj = new ErrorViewModel()
                {
                    Title = "Hata oluştu",
                    Items = res.Errors
                };

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

            return(View(res.Result));
        }
        public new BusinesLayerResult <EvernoteUser> Update(EvernoteUser data)
        {
            EvernoteUser db_user = Find(x => x.Username == data.Username || x.Email == data.Email);
            BusinesLayerResult <EvernoteUser> res = new BusinesLayerResult <EvernoteUser>();

            res.Result = data;

            if (db_user != null && db_user.Id != data.Id)
            {
                if (db_user.Username == data.Username)
                {
                    res.AddError(ErrorMessageCode.UsernameAllreadyExists, "Kullanıcı adı kayıtlı.");
                }

                if (db_user.Email == data.Email)
                {
                    res.AddError(ErrorMessageCode.EmailAllreadyExists, "E-posta adresi kayıtlı.");
                }

                return(res);
            }

            res.Result          = Find(x => x.Id == data.Id);
            res.Result.Email    = data.Email;
            res.Result.Name     = data.Name;
            res.Result.Surname  = data.Surname;
            res.Result.Password = data.Password;
            res.Result.Username = data.Username;
            res.Result.IsActive = data.IsActive;
            res.Result.IsAdmin  = data.IsAdmin;

            if (string.IsNullOrEmpty(data.ProfileImageFileName) == false)
            {
                res.Result.ProfileImageFileName = data.ProfileImageFileName;
            }

            if (base.Update(res.Result) == 0)
            {
                res.AddError(ErrorMessageCode.UserCouldNotUpdated, "Kullanıcı güncellenemedi.");
            }

            return(res);
        }
Beispiel #12
0
        public ActionResult EditProfile(EvernoteUser model, HttpPostedFileBase ProfileImage)
        {
            ModelState.Remove("ModifiedUsername");

            if (ModelState.IsValid)
            {
                if (ProfileImage != null &&
                    (ProfileImage.ContentType == "image/jpeg" ||
                     ProfileImage.ContentType == "image/JPEG" ||
                     ProfileImage.ContentType == "image/jpg" ||
                     ProfileImage.ContentType == "image/JPG" ||
                     ProfileImage.ContentType == "image/PNG" ||
                     ProfileImage.ContentType == "image/png"))
                {
                    string filename = $"user_{model.Id}.{ProfileImage.ContentType.Split('/')[1]}";

                    ProfileImage.SaveAs(Server.MapPath($"~/images/{filename}"));
                    model.ProfileImageFileName = filename;
                }
                BusinesLayerResult <EvernoteUser> res = evernoteUserMenager.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);

                //CurrentSession.Set<EvernoteUser>("login", res.Result);

                return(RedirectToAction("ShowProfile"));
            }
            return(View(model));
        }
        public BusinesLayerResult <EvernoteUser> RemoveUserById(int id)
        {
            BusinesLayerResult <EvernoteUser> res = new BusinesLayerResult <EvernoteUser>();
            EvernoteUser user = Find(x => x.Id == id);

            if (user != null)
            {
                if (Delete(user) == 0)
                {
                    res.AddError(ErrorMessageCode.UserCouldNotRemove, "Kullanıcı silinemedi.");
                    return(res);
                }
            }
            else
            {
                res.AddError(ErrorMessageCode.UserCouldNotInserted, "Kullanıcı bulunamadı.");
            }

            return(res);
        }
Beispiel #14
0
        public ActionResult Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                BusinesLayerResult <EvernoteUser> res = evernoteUserMenager.LoginUser(model);
                if (res.Errors.Count > 0)
                {
                    if (res.Errors.Find(x => x.Code == ErrorMessageCode.UserIsNotActive) != null)
                    {
                        ViewBag.SetLink = "E-Posta gönder";
                    }
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                    return(View(model));
                }

                CurrentSession.Set <EvernoteUser>("login", res.Result); // Sessionda kullanıcı bilgileri saklama.
                return(RedirectToAction("Index"));                      // Yönlendirme
            }

            return(View(model));
        }
Beispiel #15
0
        public ActionResult DeleteProfile()
        {
            BusinesLayerResult <EvernoteUser> res = evernoteUserMenager.RemoveUserById(CurrentSession.User.Id);

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

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

            evernoteUserMenager.Save();
            Session.Clear();

            return(RedirectToAction("Index"));
        }
Beispiel #16
0
        public ActionResult UserActivate(Guid id)
        {
            BusinesLayerResult <EvernoteUser> res = evernoteUserMenager.ActivateUser(id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModel notifyObj = new ErrorViewModel()
                {
                    Title = "Geçersiz İşlem",
                    Items = res.Errors
                };
                TempData["errors"] = res.Errors;
                return(View("Error", notifyObj));
            }
            OkViewModel notifyObjOk = new OkViewModel()
            {
                Title          = "Hesap Aktifleştirildi",
                RedirectingUrl = "/Home/Login"
            };

            notifyObjOk.Items.Add("Hesabınız aktifleştirildi. Artık not paylaşımı ve beğenme yapabilirsiniz.");
            return(View("Ok", notifyObjOk));
        }
Beispiel #17
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                BusinesLayerResult <EvernoteUser> res = evernoteUserMenager.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 adresine gönderddiğimiz aktivasyon linkine tıklayarak hesabımızı " +
                                    "aktive ediniz.Hesabınızı aktive etmeden not ekleyemez ve beğenme yapamazsınız.");
                return(View("Ok", notifyObj));
            }
            return(View(model));
        }
        public BusinesLayerResult <EvernoteUser> ActivateUser(Guid activateId)
        {
            BusinesLayerResult <EvernoteUser> res = new BusinesLayerResult <EvernoteUser>();

            res.Result = Find(x => x.ActivateGuid == activateId);
            if (res.Result != null)
            {
                if (res.Result.IsActive)
                {
                    res.AddError(ErrorMessageCode.UserAreadyActive, "Kullanıcı zaten aktif edilmiştir.");
                    return(res);
                }

                res.Result.IsActive = true;
                Update(res.Result);
            }
            else
            {
                res.AddError(ErrorMessageCode.ActivateIdDoesNotExists, "Aktifleştirilecek kullanıcı bulunamadı.");
            }

            return(res);
        }
        public ActionResult UserActivate(Guid id)
        {
            BusinesLayerResult <Kart> res = km.ActivateUser(id);

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

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

            OkViewModel okNotifyObj = new OkViewModel()
            {
                Title          = "Odeme Onaylandı",
                RedirectingUrl = "/Randevu/Index"
            };

            okNotifyObj.Items.Add("Odemeniz alınmıştır.Randevu günü Gidebilirsiniz.");

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