예제 #1
0
        public async Task <ActionResult> Create(PostDto post)
        {
            try
            {
                await PostGenericFacade.CreateAsync(post);


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #2
0
        // 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}");
        }