public async Task <IActionResult> Create(BoardGameModel model)
        {
            try
            {
                var result = await _boardGameService.CreateAsync(model.ToEntity());

                return(result.HasValue
                    ? CreatedJson(result.Value.ToResponse())
                    : BadRequest());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while creating new board game!");
                return(InternalServerErrorJson(ex));
            }
        }
        public async Task <IActionResult> Update(string id, BoardGameModel model)
        {
            try
            {
                var result = await _boardGameService.UpdateAsync(model.ToEntity(id));

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