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)); } }
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)); } }
public static BoardGameCategory ToEntity(this BoardGameCategoryModel model) { return(model.ToEntity(default));