Beispiel #1
0
        public MessageResult <ENote> RemoveNoteById(int id)
        {
            LikeManager    likeManager    = new LikeManager();
            CommentManager commentManager = new CommentManager();

            MessageResult <ENote> res = new MessageResult <ENote>();

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

            if (res.Result != null)
            {
                foreach (EComment item in res.Result.Comments.ToList())
                {
                    commentManager.Delete(item);
                }

                foreach (ELiked like in res.Result.Likes.ToList())
                {
                    likeManager.Delete(like);
                }

                if (Delete(res.Result) == 0)
                {
                    res.AddError(ErrorMessageCodes.CategoryCouldNotRemove, "Note could not be deleted.");
                }
                return(res);
            }
            else
            {
                res.AddError(ErrorMessageCodes.NoteCouldNotFind, "Note could not find.");
                return(res);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Note note = _noteManager.Get(x => x.Id == id);
            BussinessResult <Note> result = null;

            // TODO : Check And Remove

            if (note != null)
            {
                foreach (Liked like in note.Likes)
                {
                    _likeManager.Delete(like);
                }
                foreach (Comment comment in note.Comments)
                {
                    _commentManager.Delete(comment);
                }
                result = _noteManager.Delete(note);
            }


            if (result.Errors.Count > 0)
            {
                foreach (BussinessError error in result.Errors)
                {
                    ModelState.AddModelError("", error.Detail);
                }
                return(View(note));
            }

            TempData["NoteDelete"] = result.Successes;
            return(RedirectToAction("Index"));
        }
        public int DeleteUser(User user)
        {
            foreach (Note note in _noteM.List(x => x.User.Id == user.Id))
            {
                foreach (Comment comment in note.Comments)
                {
                    _com.Delete(comment);
                }

                foreach (Liked like in note.Likes)
                {
                    _likeM.Delete(like);
                }
                _noteM.Delete(note);
            }
            return(base.Delete(user));
        }
        public ActionResult DeleteLike(Guid blogid, int itemId)
        {
            Like like = _likeManager.Find(x => x.Id == itemId);

            if (like == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            _likeManager.Delete(like);

            CacheHelper.RemoveGetBlogsWithOutDraftDeleteFromCache();
            return(RedirectToAction("Edit", "Blog", new { @id = blogid }));
        }
    protected void article_off_Click(object sender, EventArgs e)
    {
        LinkButton article_id = (LinkButton)sender;
        Like       like       = new Like();

        like.articleId = new Guid(article_id.CommandArgument);
        Guid account_id;

        account_id     = new Guid(Request.Cookies["account_id"].Value);
        like.accountId = account_id;
        LikeManager lm = new LikeManager();

        if (lm.Delete(like))
        {
            Response.Redirect("Collectionlist.aspx");
        }
    }
Beispiel #6
0
        public override int Delete(Category category)
        {
            foreach (Note notes in category.Notes.ToList())
            {
                foreach (Liked likes in notes.Likes.ToList())
                {
                    likeManager.Delete(likes);
                }

                foreach (Comment comment in notes.Comments.ToList())
                {
                    commentManager.Delete(comment);
                }

                noteManager.Delete(notes);
            }
            return(base.Delete(category));
        }
        public ActionResult SetLikes(int noteId, bool liked)
        {
            int res = 0;

            if (SessionManager.User == null)
            {
                return(Json(new { hasErrorr = true, errorMessagee = "You must entry in system for to like.", ress = 0 }));
            }
            ELiked like = likeManager.Find(x => x.Note.Id == noteId && x.LikedUser.Id == SessionManager.User.Id);

            ENote note = noteManager.Find(x => x.Id == noteId);

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

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


                res = noteManager.Update(note);

                return(Json(new { hasErrorr = false, errorMessagee = string.Empty, ress = note.LikeCount }));
            }

            return(Json(new { hasErrorr = true, errorMessagee = "Failed.", ress = note.LikeCount }));
        }
Beispiel #8
0
        public MessageResult <ECategory> RemoveCategoryById(int id)
        {
            NoteManager    noteManager    = new NoteManager();
            LikeManager    likeManager    = new LikeManager();
            CommentManager commentManager = new CommentManager();

            MessageResult <ECategory> res = new MessageResult <ECategory>();

            res.Result = Find(x => x.Id == id);
            if (res.Result != null)
            {
                //delete
                foreach (ENote note in res.Result.Notes.ToList())
                {
                    //delete like
                    foreach (ELiked like in note.Likes.ToList())
                    {
                        likeManager.Delete(like);
                    }

                    //comment delete
                    foreach (EComment comment in note.Comments.ToList())
                    {
                        commentManager.Delete(comment);
                    }

                    //note delete
                    noteManager.Delete(note);
                }

                if (Delete(res.Result) == 0)
                {
                    res.AddError(ErrorMessageCodes.CategoryCouldNotRemove, "Category could not be deleted.");
                }
                return(res);
            }
            else
            {
                res.AddError(ErrorMessageCodes.UserCouldNotFind, "User could not find.");
            }

            return(res);
        }
Beispiel #9
0
        public ActionResult SetLikeState(int noteid, bool liked)
        {
            int res = 0;

            if (CurrentSession.User == null)
            {
                return(Json(new { hasError = true, errorMessage = "Yorumu beğenebilmek için giriş yapmalısınız", result = 0 }));
            }

            Liked like = likeManager.Find(x => x.Note.Id == noteid && x.LikedUser.Id == CurrentSession.User.Id);
            Note  note = noteManager.Find(x => x.Id == noteid);

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

            if (res > 0)
            {
                if (liked)
                {
                    note.LikeCount++;
                }
                else
                {
                    note.LikeCount--;
                }
                res = noteManager.Update(note);
                return(Json(new { hasError = false, errorMessage = string.Empty, result = note.LikeCount }));
            }
            return(Json(new { hasError = true, errorMessage = "Yorum Beğenilemedi..!", result = note.LikeCount }));
        }
        public ActionResult SetLike(int card_id, bool like)
        {
            int _result = 0;

            if (UserSession.User == null)
            {
                return(Json(new { anyError = true, errorMessage = "Please login", result = 0 }));
            }


            Like liked = likeManager.Find(x => x.Food.Id == card_id && x.LikedUsers.Id == UserSession.User.Id);

            Food food = foodManager.Find(x => x.Id == card_id);

            if (liked != null && like == false)
            {
                _result = likeManager.Delete(liked);
            }
            else if (liked == null && like == true)
            {
                _result = likeManager.Insert(new Like()
                {
                    LikedUsers = UserSession.User,
                    Food       = food
                });
            }

            if (_result > 0)
            {
                _result = foodManager.Update(food);

                return(Json(new { anyError = false, errorMessage = string.Empty }));
            }

            return(Json(new { anyError = true, errorMessage = "Error" }));
        }