예제 #1
0
 public IHttpActionResult ToggleFavPost([FromUri] GenericToggleFavFormData gtffd)
 {
     if (ModelState.IsValid)
     {
         var response = forumComplexManager.ToggleFavPost(gtffd.contentID, gtffd.userID);
         if (response.IsSuccess)
         {
             return(Ok(gtffd.contentID));
         }
         else
         {
             return(BadRequest(response.Explanation));
         }
     }
     else
     {
         string message = string.Empty;
         foreach (var modelState in ModelState.Values)
         {
             foreach (var error in modelState.Errors)
             {
                 message += error.ErrorMessage + "\n";
             }
         }
         return(BadRequest(message));
     }
 }
예제 #2
0
 public JsonResult ToggleFavPost(GenericToggleFavFormData gtffd)
 {
     if (ModelState.IsValid)
     {
         var response = forumComplexManager.ToggleFavPost(gtffd.contentID, gtffd.userID);
         if (response.IsSuccess)
         {
             return(Json(new { IsSuccess = true, ID = gtffd.contentID }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { IsSuccess = false, Error = response.Explanation }, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         string message = string.Empty;
         foreach (var modelState in ModelState.Values)
         {
             foreach (var error in modelState.Errors)
             {
                 message += error.ErrorMessage + "\n";
             }
         }
         return(Json(new { IsSuccess = false, Error = message }, JsonRequestBehavior.AllowGet));
     }
 }