Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UnComments comment = commentManager.Find(x => x.Id == id);

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

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

            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public ActionResult Edit(int?id, string text)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UnComments comment = commentManager.Find(x => x.Id == id);

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

            comment.Text = text;

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

            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }