コード例 #1
0
        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));
        }
コード例 #2
0
        public ActionResult LikedOwn(int?id)
        {
            ViewModel.DirectoryHelper = DefaultDirectoryHelper;
            ViewModel.ImageHelper     = ImageHelper;

            User user = null;

            if (id != null)
            {
                user = um.Get(x => x.Id == id.Value);
            }
            List <Note> noteListLiked = new List <Note>();

            if (user.Likes != null)
            {
                foreach (Liked like in user.Likes)
                {
                    noteListLiked.Add(nm.Get(x => x.Id == like.Note.Id));
                }
            }

            ViewModel.Notes = noteListLiked;

            return(View("Index", ViewModel));
        }
コード例 #3
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." }));
        }
コード例 #4
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"));
            }
        }
コード例 #5
0
        public IActionResult Get([FromRoute] string id, [FromQuery] string PIN)
        {
            (var pinRequired, var dataModel) = noteManager.Get(id, PIN);

            if (!pinRequired && dataModel != null)
            {
                return(Ok(new NoteViewModel
                {
                    Content = dataModel.Content,
                    Expiry = dataModel.Expiry,
                    MaxReads = dataModel.MaxReads,
                    CurrentReads = dataModel.CurrentReads
                }));
            }

            return(NotFound());
        }
コード例 #6
0
        private async void LoadDataAsync(int noteId)
        {
            note = await noteManager.Get(noteId);

            this.BindingContext = note;
        }