コード例 #1
0
        public async Task <IActionResult> Create(BoardGameCategoryModel model)
        {
            try
            {
                var result = await _boardGameCategoryService.CreateAsync(model.ToEntity());

                return(result.HasValue
                    ? CreatedJson(result.Value)
                    : BadRequest());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while creating new board game category!");
                return(InternalServerErrorJson(ex));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Update(string id, BoardGameCategoryModel model)
        {
            try
            {
                var result = await _boardGameCategoryService.UpdateAsync(model.ToEntity(id));

                return(result.HasValue
                    ? OkJson(result.Value)
                    : NotFound());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while updating board game category! " +
                                 $"Id: {id}");
                return(InternalServerErrorJson(ex));
            }
        }
コード例 #3
0
 public static BoardGameCategory ToEntity(this BoardGameCategoryModel model)
 {
     return(model.ToEntity(default));