public void PostCategory_Respository_Create() { PostCategoryModel PostCategory = new Data.PostCategoryModel(); PostCategory.Name = "Test category"; PostCategory.Alias = "Test category"; PostCategory.Status = true; PostCategoryService.Create(PostCategory); }
public async Task <ActionResult <ResultOutDto <PostCategory> > > PostPostCategory( [FromBody] TagCreateInDto createOptions) { try { return(Ok(ResultOutDtoBuilder.Success(await _categoryService.Create(createOptions)))); } catch (ExistedConflictException e) { return(Conflict(ResultOutDtoBuilder.Fail <PostCategory>(e, "Category name existed."))); } }
public HttpResponseMessage Create(HttpRequestMessage request, PostCategoryModel PostCategoryModel) { return(CreateHttpResponse(request, () => { var a = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var PostCategoryService = new PostCategoryService(); PostCategoryService.Create(PostCategoryModel); //var responseData = true; response = request.CreateResponse(HttpStatusCode.OK); } return response; })); }