Ejemplo n.º 1
0
 public ActionResult CommentDeletePartial(MCommentEdit mCommentEdit)
 {
     if (DataBase.Security.IsMCommentOwner(mCommentEdit.id, Request.Cookies["access_token"].Value))
     {
         if (ModelState.IsValid)
         {
             if (DataBase.Missions.commentdelete(mCommentEdit.id))
             {
                 ModelState.Add("status", new ModelState { Value = new ValueProviderResult("success", "Коментарий удалён", null) });
             }
             else
             {
                 ModelState.Add("status", new ModelState { Value = new ValueProviderResult("success", "произошла ошибка", null) });
             }
         }
     }
     else
     {
         ModelState.Add("status", new ModelState { Value = new ValueProviderResult("success", "разве вы владелец этого коментария? пфф", null) });
     }
     var m = new MissionView(DataBase.Missions.GetById(mCommentEdit.mid));
     return View("~/Views/Mission/Partial/CommentOperationResult.cshtml", m);
 }
Ejemplo n.º 2
0
            public static bool commentedit(MCommentEdit MCommEdit)
            {
                var edit = context.mcomments.FirstOrDefault(mcom => mcom.ID == MCommEdit.id);
                if (edit != null)
                {

                    try
                    {
                        edit.body = MCommEdit.body;
                        Save();
                        return true;
                    }
                    catch
                    {
                        return false;
                    }
                }
                return false;
            }