Ejemplo n.º 1
0
        public async Task <JResponse> CreateAsync(
            [FromBody] WriteNewsItemRequest body)
        {
            var currentUser = User.Identity as AuthenticatedUser;
            var now         = DateTime.UtcNow;
            var newsItem    = new NewsItem()
            {
                Title    = body.Title,
                AuthorId = currentUser.Id,
                Created  = now,
                Modified = now,
                Html     = body.Html
            };

            _logger.LogInformation($"Creating news item: {newsItem.Title} by {currentUser.Name}");
            await _newsItemRepository.UpdateAsync(newsItem);

            return(JResponse.OK());
        }