Exemple #1
0
        public IHttpActionResult CreateNewTopic([FromBody] NewTopicFormData ntfd)
        {
            if (ModelState.IsValid)
            {
                var response = forumComplexManager.CreateNewTopic(ntfd);
                if (!(response.IsSuccess))
                {
                    return(BadRequest(response.Explanation));
                }

                return(Ok(int.Parse(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));
            }
        }
Exemple #2
0
        public JsonResult CreateNewTopic(NewTopicFormData ntfd)
        {
            if (ModelState.IsValid)
            {
                var response = forumComplexManager.CreateNewTopic(ntfd);
                if (!(response.IsSuccess))
                {
                    return(Json(new { IsSuccess = false, Error = response.Explanation }));
                }

                return(Json(new { IsSuccess = true, ID = int.Parse(response.Explanation) }));
            }
            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 }));
            }
        }