public async Task <IActionResult> PostPhotoMemory([FromRoute] Guid countryId, [FromRoute] Guid userId, IFormFile file) { var entity = await _mappingRepository.GetById(countryId); if (entity == null) { return(NotFound($"Cannot find country with id: {countryId}!!")); } ; try { var filename = await _memoryPhotoService.CreateImage(file, Guid.NewGuid(), nameof(Country).ToLower()); var memory = new PhotoMemory() { Id = Guid.NewGuid(), UserId = userId, FileName = filename.ToString() }; _worldExplorerContext.Memories.Add(memory); await _worldExplorerContext.SaveChangesAsync(); entity.CountryPhotoMemories.Add( new PhotoMemoryDto { Id = memory.Id, FileName = memory.FileName, UserId = userId }); return(Ok(await _countryMapperRepo.Update(countryId.ToString(), entity))); } catch { return(BadRequest("Cannot save image!!")); } }