コード例 #1
0
 public async Task <IActionResult> Delete(Guid id, ShortlistContent shortlistContent)
 {
     _logger.LogInformation($"DELETE Shortlist Content with {id}");
     try
     {
         _context.ShortlistContent.Remove(shortlistContent);
         await _context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         return(BadRequest(new Response()
         {
             Message = ex.Message,
             Status = "400"
         }));
     }
     return(NoContent());
 }
コード例 #2
0
        public async Task <IActionResult> Post(Guid id, [FromBody] ShortlistContent shortlistContent)
        {
            _logger.LogInformation($"PUT Shortlist Content with id {id}");
            try
            {
                _context.ShortlistContent.Add(shortlistContent);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(BadRequest(new Response()
                {
                    Message = ex.Message,
                    Status = "400"
                }));
            }

            return(CreatedAtAction(nameof(Post), new { id }, shortlistContent));
        }