コード例 #1
0
        public async Task <ActionResult <Publication> > CreateAsync([FromBody] CreatePublicationModel model)
        {
            var author = await userProvider.GetByIdAsync(model.AuthorId);

            var(result, id) = await publicationService.CreateAsync(model.Content, author);

            if (!result.Successed)
            {
                return(BadRequest(result.ToProblemDetails()));
            }

            return(Created(Url.Action("GetById", new { id }), await publicationService.GetByIdAsync(id)));
        }