Пример #1
0
 public IHttpActionResult ToggleFavTopic([FromUri] GenericToggleFavFormData gtffd)
 {
     if (ModelState.IsValid)
     {
         var response = forumComplexManager.ToggleFavTopic(gtffd.contentID, gtffd.userID);
         if (response.IsSuccess)
         {
             return(Ok());
         }
         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 ToggleFavTopic(GenericToggleFavFormData gtffd)
 {
     if (ModelState.IsValid)
     {
         var response = forumComplexManager.ToggleFavTopic(gtffd.contentID, gtffd.userID);
         if (response.IsSuccess)
         {
             return(Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { IsSuccess = true, 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 = true, Error = message }, JsonRequestBehavior.AllowGet));
     }
 }