private async Task AddGameImage(string name, string path, int gameId)
        {
            var logoPath = new ImageGame
            {
                Name    = name,
                DirPath = path,
                GameId  = gameId
            };

            await _context.ImageGame.AddAsync(logoPath);

            await _context.SaveChangesAsync();
        }
Example #2
0
 public async Task <IServiceResult> PostImageGame([FromBody] ImageGame imageGame)
 {
     try
     {
         _context.ImageGames.Add(imageGame);
         if (!await _unitOfWork.CompleteAsync())
         {
             throw new SaveFailedException(nameof(imageGame));
         }
         _logger.LogInformation($"Image {imageGame.Id}  created.");
         return(new ServiceResult(payload: imageGame.UrlOnline));
     }
     catch (Exception e)
     {
         _logger.LogError($"Can't create  a image  of game  {imageGame.Id}. {e.Message}");
         return(new ServiceResult(false, message: e.Message));
     }
 }