public IHttpActionResult AddPost(int userId, PostForCreationDTO model) { if (!ModelState.IsValid) { return(BadRequest("girdiğiniz bilgiler hatalı")); } Post post = new Post { Body = model.Body, Title = model.Title, UserId = userId, ImageUrl = model.ImageUrl, DateCreated = DateTime.UtcNow, CategoryId = model.CategoryId, SubCategoryId = model.SubCategoryId }; try { _postRepository.AddPostWithStatsAndCategory(post, model.SubCategoryId); } catch (Exception) { throw; } return(Ok()); }
public IActionResult AddPost(int userId, PostForCreationDTO model) { if (!ModelState.IsValid) { return(BadRequest(Messages.ModelNullOrEmpty)); } Post post = new Post { Body = model.Body, Title = model.Title, UserId = userId, ImageUrl = model.ImageUrl, DateCreated = DateTime.UtcNow, CategoryId = model.CategoryId, SubCategoryId = model.SubCategoryId }; _postService.Create(post, model.SubCategoryId); return(Ok()); }