public async Task <IActionResult> AddCard([FromRoute] Guid deckId, [FromForm] CreationCardDto dto) { if (!ModelState.IsValid) { return(UnprocessableEntity(ModelState)); } var deck = await deckRepo.FindAsync(deckId); if (deck is null) { return(NotFound()); } var cardDbo = mapper.Map <CreationCardDto, CardDbo>(dto); cardDbo.ImagePath = await ImageStore.SaveImage(dto.Image?.OpenReadStream(), '.' + dto.Image?.FileName.Split('.')[1]); cardDbo = await deckRepo.AddCard(deckId, cardDbo); if (cardDbo is null) { throw new AggregateException(); } return(CreatedAtRoute(nameof(GetCardById), new { deckId, cardId = cardDbo.Id }, mapper.Map <CardDbo, CardResult>(cardDbo))); }