public IActionResult AddFish([FromBody] Fish fish) { try { //Access level var id = _accountService.GetCurrentUserId(); var aq = _aquariumService.GetAquariumById(fish.AquariumId); var access = _accountService.CanModify(id, aq); if (!access) { return(Unauthorized()); } _logger.LogInformation("POST /v1/Fish/Add called"); var newFish = _fishService.CreateFish(fish); return(CreatedAtAction(nameof(GetFishById), newFish)); } catch (Exception ex) { _logger.LogError($"POST /v1/Fish/Add caught exception: { ex.Message } Details: { ex.ToString() }"); return(BadRequest()); } }
public async Task <IActionResult> CreateFish([FromBody] CreateFishRequest request) { var response = await _fishService.CreateFish(request); return(SendResponse(response)); }