Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            UnNotes notes = noteManager.Find(x => x.Id == id);

            noteManager.Delete(notes);
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(UnComments comment, int?noteid)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUsername");

            if (ModelState.IsValid)
            {
                if (noteid == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                UnNotes note = noteManager.Find(x => x.Id == noteid);

                if (note == null)
                {
                    return(new HttpNotFoundResult());
                }

                comment.Note  = note;
                comment.Owner = SessionManager.User;

                if (commentManager.Insert(comment) > 0)
                {
                    return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public ActionResult Create(UnNotes notes)
        {
            ModelState.Remove("UpdatedDate");
            ModelState.Remove("CreatedDate");
            ModelState.Remove("UpdatedUserName");
            if (ModelState.IsValid)
            {
                notes.Owner = SessionManager.User;
                noteManager.Insert(notes);
                return(RedirectToAction("Index"));
            }

            ViewBag.HashtagsId = new SelectList(hastagManager.List(), "Id", "Code", notes.HashtagsId);
            return(View(notes));
        }
Exemple #4
0
        // Not Detay Görüntüleme
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UnNotes notes = noteManager.Find(x => x.Id == id);

            if (notes == null)
            {
                return(HttpNotFound());
            }
            return(View(notes));
        }
Exemple #5
0
        // Not düzenleme işlemi(notun gösterildiği sayfaya gönderildiği aşama)
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UnNotes notes = noteManager.Find(x => x.Id == id);

            if (notes == null)
            {
                return(HttpNotFound());
            }
            ViewBag.HashtagsId = new SelectList(hastagManager.List(), "Id", "Code", notes.HashtagsId);
            return(View(notes));
        }
Exemple #6
0
        public ActionResult GetNoteText(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UnNotes note = noteManager.Find(x => x.Id == id);

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

            return(PartialView("_PartialNoteText", note));
        }
        public ActionResult ShowNoteComments(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UnNotes note = noteManager.ListQueryable().Include("Comments").FirstOrDefault(x => x.Id == id);

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

            return(PartialView("_PartialComments", note.Comments));
        }
Exemple #8
0
        public ActionResult InTheBag(int noteid, bool baged)
        {
            int res = 0;

            if (SessionManager.User == null)
            {
                return(Json(new { hasError = true, errorMessage = "Giriş yapmış kullanıcılar çantaya not atabilir!", result = 0 }));
            }

            UnBag bag =
                bagManager.Find(x => x.Note.Id == noteid && x.BagUser.Id == SessionManager.User.Id);

            UnNotes note = noteManager.Find(x => x.Id == noteid);

            if (bag != null && baged == false)
            {
                res = bagManager.Delete(bag);
            }
            else if (bag == null && baged == true)
            {
                res = bagManager.Insert(new UnBag()
                {
                    BagUser = SessionManager.User,
                    Note    = note
                });
            }

            if (res > 0)
            {
                if (baged)
                {
                    note.BagTotal++;
                }
                else
                {
                    note.BagTotal--;
                }

                res = noteManager.Update(note);

                return(Json(new { hasError = false, errorMessage = string.Empty, result = note.BagTotal }));
            }

            return(Json(new { hasError = true, errorMessage = "Çantaya not atma işlemi gerçekleştirilemedi.", result = note.BagTotal }));
        }
Exemple #9
0
        public ActionResult SetLikeState(int noteid, bool liked)
        {
            int res = 0;

            if (SessionManager.User == null)
            {
                return(Json(new { hasError = true, errorMessage = "Giriş yapmış kullanıcılar not beğenebilir!", result = 0 }));
            }

            UnLike like =
                likedManager.Find(x => x.Note.Id == noteid && x.LikedUser.Id == SessionManager.User.Id);

            UnNotes note = noteManager.Find(x => x.Id == noteid);

            if (like != null && liked == false)
            {
                res = likedManager.Delete(like);
            }
            else if (like == null && liked == true)
            {
                res = likedManager.Insert(new UnLike()
                {
                    LikedUser = SessionManager.User,
                    Note      = note
                });
            }

            if (res > 0)
            {
                if (liked)
                {
                    note.LikeTotal++;
                }
                else
                {
                    note.LikeTotal--;
                }

                res = noteManager.Update(note);

                return(Json(new { hasError = false, errorMessage = string.Empty, result = note.LikeTotal }));
            }

            return(Json(new { hasError = true, errorMessage = "Beğenme işlemi gerçekleştirilemedi.", result = note.LikeTotal }));
        }
Exemple #10
0
        public ActionResult Edit(UnNotes notes)
        {
            ModelState.Remove("UpdatedDate");
            ModelState.Remove("CreatedDate");
            ModelState.Remove("UpdatedUserName");
            if (ModelState.IsValid)
            {
                UnNotes unote = noteManager.Find(x => x.Id == notes.Id);
                unote.Draft      = notes.Draft;
                unote.HashtagsId = notes.HashtagsId;
                unote.Text       = notes.Text;
                unote.Title      = notes.Title;

                noteManager.Update(unote);

                return(RedirectToAction("Index"));
            }
            ViewBag.HashtagsId = new SelectList(hastagManager.List(), "Id", "Code", notes.HashtagsId);
            return(View(notes));
        }