コード例 #1
0
        public async Task <IActionResult> Post([FromBody] NewsViewModel viewModel)
        {
            await AuthorizeHostAsync(NewsFunctionName);

            var entity = viewModel.Map <NewsViewModel, NewsItem>();

            entity.Blob = await GetEmbeddedBlobAsync(viewModel.BlobId);

            await _newsService.CreateAsync(entity, GetEmbeddedUser(), GetClientIP());

            return(Created(string.Empty, entity.Id));
        }
コード例 #2
0
        public async Task <IActionResult> Put(string id, [FromBody] NewsViewModel viewModel)
        {
            await AuthorizeHostAsync(NewsFunctionName);

            var entity = viewModel.Map <NewsViewModel, NewsItem>();

            entity.Id   = id;
            entity.Blob = await GetEmbeddedBlobAsync(viewModel.BlobId);

            var result = await _newsService.UpdateAsync(entity, GetEmbeddedUser(), GetClientIP());

            if (!result)
            {
                return(NotFound());
            }

            return(NoContent());
        }