Exemple #1
0
        public ActionResult AddArticle(ArticleDetailViewModel model)
        {
            if (ModelState.IsValid)
            {
                //veritabanında veri olmadığı için bir şey getirilmiyor bu yüzden direkt bu şekilde yazılır
                model.Article.ArticleCreatedUserId  = ((User)Session["CurrentUser"]).Id;
                model.Article.ArticleCreatedDate    = DateTime.Now;
                model.Article.ArticleModifiedDate   = DateTime.Now;
                model.Article.ArticleModifiedUserId = ((User)Session["CurrentUser"]).Id;
                model.Article.User = ((User)Session["CurrentUser"]);
                new ArticleManager().Add(model.Article);
            }

            else
            {
                ErrorViewModal errorViewModel = new ErrorViewModal()
                {
                    Title          = "Model Yanlış!",
                    RedirectingUrl = "/Article/AddArticle"
                };

                return(View("Error", errorViewModel));
            }
            return(RedirectToAction("ListArticle", "Article"));
        }
Exemple #2
0
        public ActionResult Login(string email, string password)
        {
            ErrorViewModal model = new ErrorViewModal();

            //to do:
            //1-Kullanıcı bilgileri verittabanında var mı ve doğru mu kontrol edilecek
            //2-Eğer bilgiler doğruysa session içerisinde user nesnesi tutulacak
            //3-Session doldurulduktan sonra home/indexer e yönlendirilecek
            //4-Kullanıcı bilgileri yanlış ise hata mesajı oluşturularak hata ekranına yönlendirilecek
            if (ModelState.IsValid)
            {
                var userList = _userManager.GetAll();
                var user     = _userManager.Find(x => x.Email == email && x.Password == password);
                if (user != null)
                {
                    Session["CurrentUser"] = user;
                    return(RedirectToAction(actionName: "Index", controllerName: "Home"));
                }

                else
                {
                    return(View("Index", model));
                }
            }

            return(RedirectToAction("Index", model));
        }
Exemple #3
0
        public ActionResult EditProfile(NotlaGelUser 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;
                }

                BusinessLayerResult <NotlaGelUser> res = NotlaGelUserManager.UpdateProfile(model);

                if (res.Errors.Count > 0)
                {
                    ErrorViewModal errorNotifyObj = new ErrorViewModal()
                    {
                        Items          = res.Errors,
                        Title          = "Profil Güncellenemedi.",
                        RedirectingUrl = "/Home/EditProfile"
                    };
                    return(View("Error", errorNotifyObj));
                }
                CurrentSession.Set <NotlaGelUser>("login", res.Result);

                return(RedirectToAction("ShowProfile"));
            }
            return(View(model));
        }
Exemple #4
0
        public ActionResult EditProfile()
        {
            BusinessResult <EvernoteUser> res = evernoteUserManager.GetUserById(CurrentSession.User.Id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModal ErrnotifyObj = new ErrorViewModal()
                {
                    Title = "Hata Oluştu",
                    Items = res.Errors
                };
                return(View("Error", ErrnotifyObj));
            }

            return(View(res.Result));
        }
Exemple #5
0
        public ActionResult EditProfile()
        {
            BusinessLayerResult <NotlaGelUser> res = NotlaGelUserManager.GetUserById(CurrentSession.user.Id);

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

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

            return(View(res.Result));
        }
Exemple #6
0
        public ActionResult DeleteProfile()
        {
            BusinessLayerResult <NotlaGelUser> res = NotlaGelUserManager.RemoveUserById(CurrentSession.user.Id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModal errorNotifyObject = new ErrorViewModal()
                {
                    Items          = res.Errors,
                    Title          = "Profil Silinemedi.",
                    RedirectingUrl = "/Home/ShowProfile"
                };
                return(View("Error", errorNotifyObject));
            }
            Session.Clear();

            return(RedirectToAction("Index"));
        }
Exemple #7
0
        public ActionResult TestNotify()
        {
            ErrorViewModal modal = new ErrorViewModal()
            {
                Header             = "Yönlendirme..",
                Title              = "Error Test",
                RedirectingTimeout = 3000,
                Items              = new List <ErrorMessageObj>()
                {
                    new ErrorMessageObj()
                    {
                        Message = " Test başarılı 1 "
                    },
                    new ErrorMessageObj()
                    {
                        Message = " Test başarılı 2 "
                    }
                }
            };

            return(View("Error", modal));
        }
Exemple #8
0
        public ActionResult UserActivate(Guid id)
        {
            BusinessResult <EvernoteUser> res = evernoteUserManager.ActivateUser(id);

            if (res.Errors.Count > 0)
            {
                ErrorViewModal ErrnotifyObj = new ErrorViewModal()
                {
                    Title = "Geçersiz İşlem",
                    Items = res.Errors
                };
                return(View("Error", ErrnotifyObj));
            }

            OKViewModal OknotifyObj = new OKViewModal()
            {
                Title          = "Hesap Aktifleştirildi.",
                RedirectingUrl = "/Home/LogIn"
            };

            OknotifyObj.Items.Add("Your Account activated. You can do shared and like.");
            return(View("Ok", OknotifyObj));
        }
Exemple #9
0
        public ActionResult AddCategory(CategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.Category.CategoryCreatedUserId  = ((User)Session["CurrentUser"]).Id;
                model.Category.CategoryCreatedDate    = DateTime.Now;
                model.Category.CategoriModifiedDate   = DateTime.Now;
                model.Category.CategoryModifiedUserId = ((User)Session["CurrentUser"]).Id;
                model.Category.User = ((User)Session["CurrentUser"]);
                new CategoryManager().Add(model.Category);
            }

            else
            {
                ErrorViewModal errorViewModel = new ErrorViewModal()
                {
                    Title          = "Model Yanlış!",
                    RedirectingUrl = "/Category/AddCategory"
                };

                return(View("Error", errorViewModel));
            }
            return(RedirectToAction("ListCategory", "Category"));
        }
Exemple #10
0
        public ActionResult UserActivate(Guid id)
        {
            BusinessLayerResult <NotlaGelUser> res = NotlaGelUserManager.ActivateUser(id);

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

                return(View("Error", errorNotifyObj));
            }
            OkViewModal okNotifyObj = new OkViewModal()
            {
                Title          = "Hesap Aktifleştirildi",
                RedirectingUrl = "/Home/Login",
            };

            okNotifyObj.Items.Add("Hesabınız Aktifleştirildi. Artık not paylaşabilirsiniz.");

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