Example #1
0
        public ActionResult UserList()
        {
            ViewModel.DirectoryHelper = DefaultDirectoryHelper;
            ViewModel.ImageHelper     = ImageHelper;

            if (TempData["newUserAdd"] != null)
            {
                ViewBag.ResultError = TempData["newUserAdd"];
            }
            if (TempData["userEdit"] != null)
            {
                ViewBag.ResultError = TempData["userEdit"];
            }
            if (TempData["Delete"] != null)
            {
                ViewBag.ResultError = TempData["Delete"];
            }
            string      currentToken = CurrentCookieTester.GetCurrentToken(CookieKeys.signedUserToken);
            List <User> _userList    = userManager.List(x => x.IsDeleted == false && x.IsAdmin == false && x.Token.ToString() != currentToken);

            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "User/UserList");

            ViewModel.Users = _userList;

            return(View(ViewModel));
        }
Example #2
0
 public void OnAuthorization(AuthorizationContext filterContext)
 {
     if (CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken) != null && CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken).IsAdmin == false)
     {
         filterContext.Result = new RedirectResult("/MyEvernoteHome/AccessDenied");
     }
 }
 public void OnAuthorization(AuthorizationContext filterContext)
 {
     if (CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken) == null)
     {
         filterContext.Result = new RedirectResult("/MyEvernoteHome/Login");
     }
 }
        // GET: Note
        public ActionResult Index()
        {
            User currentUser = CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken);

            if (TempData["NoteUpdate"] != null)
            {
                ViewBag.ResultMethod = TempData["NoteUpdate"];
            }
            if (TempData["NoteDelete"] != null)
            {
                ViewBag.ResultMethod = TempData["NoteDelete"];
            }
            if (TempData["NoteInsert"] != null)
            {
                ViewBag.ResultMethod = TempData["NoteInsert"];
            }
            if (currentUser != null)
            {
                if (currentUser.IsAdmin == false)
                {
                    return(View(_noteManager.List(x => x.IsDeleted == false && x.User.Id == currentUser.Id).OrderBy(x => x.NoteTitle).ToList()));
                }
            }
            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "Note/Index");
            return(View(_noteManager.List(x => x.IsDeleted == false).OrderBy(x => x.NoteTitle).ToList()));
        }
Example #5
0
 public void OnAuthorization(AuthorizationContext filterContext)
 {
     if (CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken) != null)
     {
         filterContext.Result = new RedirectResult("/" + CurrentCookieTester.GetCurrentUrl(CookieKeys.updateableUrl));
     }
 }
Example #6
0
        public ActionResult AccessDenied()
        {
            if (CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken) == null)
            {
                return(new RedirectResult("/MyEvernoteHome/Index"));
            }

            ErrorViewModel errorModel = new ErrorViewModel()
            {
                IsRedirecting   = true,
                RedirectingInfo = "Esas Sehifeye Yonlendirilirsiniz...",
                RedirectSeconds = 8,
                RedirectUrl     = "/MyEvernoteHome/Index",
                Title           = "Hormetli" + CurrentCookieTester.GetCurrentUsername(CookieKeys.signedUserToken),
                Details         = new List <BussinessError>
                {
                    new BussinessError
                    {
                        AlertColor = "danger",
                        Detail     = "Icazeniz Olmayan Sorgu Isteyi Gondermisiniz.",
                        ErrorCode  = InformingOrError.ErrorAccessDenied
                    }
                },
                Todo = "Sadece Icazeniz Olan Bolmelere Daxil Olmaginiz Xais Olunur"
            };

            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "MyEvernoteHome/Index");
            return(View("Error", errorModel));
        }
Example #7
0
        public ActionResult Create(Comment comment, int?noteID)
        {
            User user = CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken);
            Note note = _noteManager.Get(x => x.Id == noteID);

            if (note == null || user == null)
            {
                return(HttpNotFound());
            }

            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUsername");

            if (ModelState.IsValid)
            {
                comment.Note = note;
                comment.User = user;

                if (_commentManager.Insert(comment) > 0)
                {
                    return(Json(new { result = 1, message = "Komment Elave Olundu" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { result = 0, message = "Komment Elave Olunmadi" }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { result = -1, message = "Qeyd Etdiyiniz Komment setri minimum 1, maksimum 3000 simvol hecminde olmalidir." }));
        }
Example #8
0
        // GET: Category
        public ActionResult Index()
        {
            ViewBag.Success = TempData["successIndex"];
            List <Category> currentCategories = _categoryManager.List(x => x.IsDeleted == false);

            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "Category/Index");

            return(View(currentCategories));
        }
Example #9
0
        public ActionResult SetLikeProcess(int?id, bool isInsert)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Note note = _noteManager.Get(x => x.Id == id.Value && x.IsDeleted == false);
            User user = CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken);

            if (note == null && user == null)
            {
                return(new RedirectResult("/MyEvernoteHome/Index"));
            }

            if (isInsert == true)
            {
                Liked liked = new Liked();
                liked.Note = note;
                liked.User = user;

                if (_likeManager.Get(x => x.Note.Id == note.Id && x.User.Id == user.Id) == null)
                {
                    if (_likeManager.Insert(liked) > 0)
                    {
                        note.LikeCount++;
                        _noteManager.Update(note);
                        return(Json(new { result = 1, likeCount = note.LikeCount, likeStatus = isInsert }, JsonRequestBehavior.AllowGet));
                    }
                    return(Json(new { result = 0, message = "Like Prosesi Ugursuz Oldu. Sistemde Xeta Yarandi Zehmet Olmasa Birazdan Tekrar Cehd Edin", likeCount = note.LikeCount, likeStatus = !isInsert }, JsonRequestBehavior.AllowGet));
                }

                return(new RedirectResult("/MyEvernoteHome/Index"));
            }
            else
            {
                Liked deletingLike = _likeManager.Get(x => x.Note.Id == note.Id && x.User.Id == user.Id);

                if (deletingLike != null)
                {
                    if (_likeManager.PermanentlyDelete(deletingLike) > 0)
                    {
                        note.LikeCount--;
                        _noteManager.Update(note);
                        return(Json(new { result = 1, likeCount = note.LikeCount, likeStatus = isInsert }, JsonRequestBehavior.AllowGet));
                    }

                    return(Json(new { result = 0, message = "Post Beyenilme Prosesi zamani Xeta Formalasdi. Postunuz Beyenilmedi. Zehmet Olmasa Birazdan Tekrar Cehd Edin", likeCount = note.LikeCount, likeStatus = !isInsert }));
                }

                //return Json(new { result = -1, message = "Post Daha Once Dislike Olunmusdur. Sisteminizde Xeta Yaranmisdir Zehmet Olmasa Sehifeni Yenileyin Ve Tekrar Cehd Edin"});
                return(new RedirectResult("/MyEvernoteHome/Index"));
            }
        }
Example #10
0
        public ActionResult ShowProfile()
        {
            User user = null;

            if (CurrentCookieTester.CookieIsExist(CookieKeys.signedUserToken))
            {
                user = userManager.GetUserForCookie(CurrentCookieTester.GetCurrentToken(CookieKeys.signedUserToken));
            }
            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "User/ShowProfile");
            return(View(user));
        }
Example #11
0
        public ActionResult GetLikedIds(int[] ids)
        {
            List <int> likedIds    = new List <int>();
            User       currentUser = CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken);

            if (currentUser != null)
            {
                likedIds = _likeManager.List(x => x.User.Id == currentUser.Id)
                           .Where(x => ids.Contains(x.Note.Id)).GroupBy(x => x.Note.Id).Select(x => x.First())
                           .Select(x => x.Note.Id).ToList();
            }

            return(Json(new { result = likedIds }));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Note note = _noteManager.Get(x => x.Id == id.Value);

            if (note == null)
            {
                return(HttpNotFound());
            }
            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, $"Note/Details/{id}");
            return(View(note));
        }
Example #13
0
        // GET: Category/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Category category = _categoryManager.Get(x => x.Id == id.Value);

            if (category == null)
            {
                return(HttpNotFound());
            }

            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, $"Category/Edit/{id}");

            return(View(category));
        }
Example #14
0
        public ActionResult UserDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            User user = userManager.Get(x => x.Id == id.Value);

            if (user == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, $"User/UserDetails/{id}");

            return(View(user));
        }
Example #15
0
        // Page Actions -- Start
        public ActionResult Index()
        {
            Test test = new Test();

            ViewModel.ImageHelper     = ImageHelper;
            ViewModel.DirectoryHelper = DefaultDirectoryHelper;

            if (nm.List() != null)
            {
                ViewModel.Notes = nm.List(x => x.IsDeleted == false && x.IsDraft == false && x.User.IsBanned == false && x.User.IsConfirmed == true && x.User.IsDeleted == false).OrderByDescending(x => x.CreatedOn).ToList();

                return(View(ViewModel));
                //return View(nm.GetNotesByQuery().OrderByDescending(x=>x.ModifiedOn).ToList());
            }

            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "MyEvernoteHome/Index");

            return(View(ViewModel));
        }
Example #16
0
        public ActionResult DeleteProfile(string password, int currentId)
        {
            User user = userManager.GetUserByID(currentId);

            if (user != null)
            {
                if (user.Password == "demoxxx123")
                {
                    if (user.Password == password)
                    {
                        int result = userManager.DeleteUser(user);
                        if (result > 0)
                        {
                            CurrentCookieTester.ExpireCookie(CookieKeys.signedUserToken, 6);
                            return(RedirectToAction("Index", "MyEvernoteHome"));
                        }
                        ViewBag.Error = "Silme Emeliyyati Heyata Kecirilmedi. Zehmet Olmasa Birazdan Tekrar Cehd Edin...";
                    }
                    else
                    {
                        ViewBag.Error = "Girdiyiniz Sifre Dogru Deyil !";
                    }
                }
                else
                {
                    if (Crypto.VerifyHashedPassword(user.Password, password))
                    {
                        int result = userManager.DeleteUser(user);
                        if (result > 0)
                        {
                            CurrentCookieTester.ExpireCookie(CookieKeys.signedUserToken, 6);
                            return(RedirectToAction("Index", "MyEvernoteHome"));
                        }
                        ViewBag.Error = "Silme Emeliyyati Heyata Kecirilmedi. Zehmet Olmasa Birazdan Tekrar Cehd Edin...";
                    }
                    else
                    {
                        ViewBag.Error = "Girdiyiniz Sifre Dogru Deyil !";
                    }
                }
            }
            return(View());
        }
Example #17
0
        public ActionResult ActivationConfirming(string confirm)
        {
            BussinessProcessedType <User> bpResult = um.ConfirmUser(confirm);

            if (bpResult.ProcessedCount > 0)
            {
                CurrentCookieTester.SetCookie(CookieKeys.signedUserToken, bpResult.Entity.Token.ToString());
                return(RedirectToAction("Index"));
            }

            if (bpResult.Status == InformingOrError.InformMailAlreadyConfirmed)
            {
                ViewBag.userName = bpResult.Entity.Username;

                WarningViewModel model = new WarningViewModel()
                {
                    RedirectingInfo = "Esas Sehifeye Yonlendirilirsiniz...",
                    RedirectSeconds = 8,
                    RedirectUrl     = "/MyEvernoteHome/Index",
                    Todo            = "Hesabiniz Tesdiqlenmisdir. Artiq Istediyiniz Zaman Login Sehifesinden Hesabiniza Daxil Ola bilersiniz."
                };
                model.Details.Add("Hesabiniz Daha Once Tesdiqlenmisdir. Buna Gore Artiq Aktivlesdirme Linki Passivdir.");

                return(View("Warning", model));
            }

            ViewBag.userName = null;
            ErrorViewModel modelUnknown = new ErrorViewModel()
            {
                RedirectingInfo = "Esas Sehifeye Yonlendirilirsiniz...",
                RedirectSeconds = 8,
                RedirectUrl     = "/MyEvernoteHome/Index",
                Todo            = "Zehmet Olmasa Biraz Gozledikden Sonra Tekrar Cehd Edin"
            };

            modelUnknown.Details.Add(new BussinessError
            {
                ErrorCode = InformingOrError.ErrorRegisterFailedSendingConfirmEmail,
                Detail    = "Hesabinizda Tesdiqlenme Emeliyyati Aparilarken Xeta Yarandi."
            });
            return(View("Error", modelUnknown));
        }
Example #18
0
        public string GetCurrentUsername()
        {
            string      resultMain;
            UserManager usm = new UserManager();

            if (CurrentCookieTester.CookieIsExist(CookieKeys.signedUserToken) == true)
            {
                resultMain = usm.CheckCookieThenGetResponse(CurrentCookieTester.GetCurrentToken(CookieKeys.signedUserToken));
                if (resultMain == null)
                {
                    CurrentCookieTester.ExpireCookie(CookieKeys.signedUserToken, 6);
                }
            }
            else
            {
                DefaultCommon defaultCommon = new DefaultCommon();
                resultMain = DefaultCommon.UserName;
            }

            return(resultMain);
        }
Example #19
0
 public ActionResult Login(UserLogin usl)
 {
     if (ModelState.IsValid)
     {
         BussinessResult <User> result = um.LoginUserCheck(usl);
         if (result.Errors.Count > 0)
         {
             foreach (BussinessError bse in result.Errors)
             {
                 ModelState.AddModelError(bse.Subject, bse.Detail);
             }
         }
         else
         {
             CurrentCookieTester.SetCookie(CookieKeys.signedUserToken, result.Result.Token.ToString());
             return(RedirectToAction("Index"));
         }
     }
     // User'i Session'da tut
     // Yonlendir
     return(View(usl));
 }
Example #20
0
        // GET: Category/Create
        public ActionResult Create()
        {
            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "Category/Create");

            return(View());
        }
Example #21
0
        // Create Account -- End
        #endregion

        #region Logout
        public ActionResult Logout()
        {
            CurrentCookieTester.ExpireCookie(CookieKeys.signedUserToken, 6);
            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "MyEvernoteHome/Index");
            return(RedirectToAction("Index", "MyEvernoteHome"));
        }
Example #22
0
 public ActionResult Contact()
 {
     CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "MyEvernoteHome/Contact");
     return(View());
 }
        public ActionResult Create(Note note, HttpPostedFileBase notePhoto, int?categoryId)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUsername");

            Category currentCategory = null;

            if (categoryId != null)
            {
                currentCategory = _categoryManager.Get(x => x.Id == categoryId);
            }
            if (currentCategory == null)
            {
                ModelState.AddModelError("", "Secdiyiniz Kateqoriya Tapilmadi. Zehmet Olmasa Tekrar Cehd Edin");
                return(View(note));
            }
            else
            {
                note.Category = currentCategory;
            }

            if (ModelState.IsValid)
            {
                if (notePhoto != null)
                {
                    if (notePhoto.ContentType.Split('/')[1] == "jpg" ||
                        notePhoto.ContentType.Split('/')[1] == "jpeg" ||
                        notePhoto.ContentType.Split('/')[1] == "png")
                    {
                        string ownPath  = Server.MapPath(directoryHelper.NoteImagesDir);
                        string fileName = $"noteProfilePhoto_{DateTime.Now.Day}_{DateTime.Now.Month}_{DateTime.Now.Year}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.{notePhoto.ContentType.Split('/')[1]}";
                        if (!Directory.Exists(ownPath))
                        {
                            Directory.CreateDirectory(ownPath);
                        }
                        notePhoto.SaveAs(ownPath + fileName);
                        note.ImageCap = fileName;
                    }
                    else
                    {
                        ModelState.AddModelError("", "Daxil Etdiyiniz Fayl Formati Duzgun Formatda Deyil.");
                        return(View(note));
                    }
                }

                note.User = CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken);
                BussinessResult <Note> result = _noteManager.Insert(note);
                if (result.Errors.Count > 0)
                {
                    foreach (BussinessError error in result.Errors)
                    {
                        ModelState.AddModelError("", error.Detail);
                    }
                    return(View(result.Result));
                }

                TempData["NoteInsert"] = result.Successes;
                return(RedirectToAction("Index"));
            }

            return(View(note));
        }
Example #24
0
        public ActionResult EditProfile()
        {
            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "User/EditProfile");

            return(View());
        }
Example #25
0
        public ActionResult CreateUser()
        {
            CurrentCookieTester.SetCookie(CookieKeys.updateableUrl, "User/CreateUser");

            return(View());
        }