コード例 #1
0
        public IHttpActionResult EditPost(PostEditVm post)
        {
            if (!ModelState.IsValid)
                return BadRequest("Data for edit  is not valid");

            var isPostEdited = _postsBo.EditPost(
                                                post.Id,
                                                post.Title,
                                                post.Content,
                                                post.IsEnableComments);
            return !isPostEdited ? BadRequest("Post is not Exist") : (IHttpActionResult)Ok();
        }
コード例 #2
0
        public IHttpActionResult AddNewPost(PostEditVm post)
        {
            if (!ModelState.IsValid)
                return BadRequest("Data for creating a new post is not valid");

            var isPostCreated = _postsBo.AddNewPost(
                                                Convert.ToInt32(CurrentUserId),
                                                post.Title, post.Content,
                                                post.IsEnableComments);

            return !isPostCreated ? BadRequest("Post is not Created. Title of post alresdy exsist.") : (IHttpActionResult)Ok();
        }