public async Task <ActionResult> Create(PostDto post) { try { await PostGenericFacade.CreateAsync(post); return(RedirectToAction("Index")); } catch { return(View()); } }
// POST: api/Posts public async Task <string> Post(PostDto entity) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var postId = await PostGenericFacade.CreateAsync(entity); if (postId.Equals(0)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } return($"Created Post with id: {postId}"); }