public JsonResult<ResponseViewModel<bool>> PostEditIntegrationGame(IntegrationGameViewModel integrationGame)
 {
     var response =
         ServiceExecutor.Execute(
             () => _managementIntegrationGamesService.PutIntegrationGame(integrationGame));
     return Json(response);
 }
 public bool PutIntegrationGame(IntegrationGameViewModel game)
 {
     game.GameTranslations = FillAvailableTranslation(game.Id);
     var entity = ValidateGetIntegrationGameDetailById(game.IntegrationGameId);
     entity.IntegrationGameName = game.GameName;
     entity.IntegrationGameDescription = game.GameDescription;
     RepositoryFactory.Context.SaveChanges();
     game.GameTranslations.ForEach(x =>
     {
         if (x.HasTranslation)
         {
             entity =
                 RepositoryFactory.Context.IntegrationGameDetails.FirstOrDefault(
                     z => z.IntegrationGame.Id == game.Id && z.Language.Id == x.Language.Id);
             game.IntegrationGameDetailModels.ForEach(g =>
             {
                 var integrationGameFeatureDao = entity?.IntegrationGameFeatures.FirstOrDefault(
                     z => z.GameFeatureLanguage.GameFeature.Id == g.GameFeatureId);
                 if (integrationGameFeatureDao != null)
                     integrationGameFeatureDao
                         .GameFeatureDetailLanguage =
                         RepositoryFactory.Context.GameFeatureDetailLanguages.FirstOrDefault(
                             h =>
                                 h.GameFeatureDetail.Id == g.GameFeatureDetailId &&
                                 h.Language.Id == x.Language.Id);
             });
             RepositoryFactory.Context.SaveChanges();
             entity = null;
         }
     });
     return true;
 }
 private bool RemoveAllGameTranslation(IntegrationGameViewModel game)
 {
     var gameFeatureEntity =
                RepositoryFactory.Context.IntegrationGameFeatures.Where(
                    x => x.IntegrationGameDetail.IntegrationGame.Id == game.Id);
     RepositoryFactory.Context.IntegrationGameFeatures.RemoveRange(gameFeatureEntity);
     var gameEntity =
         RepositoryFactory.Context.IntegrationGameDetails.Where(
             x => x.IntegrationGame.Id == game.Id);
     RepositoryFactory.Context.IntegrationGameDetails.RemoveRange(gameEntity);
     var mainGameEntity =
         RepositoryFactory.Context.IntegrationGames.FirstOrDefault(x => x.Id == game.Id);
     RepositoryFactory.Context.IntegrationGames.Remove(mainGameEntity);
     RepositoryFactory.Context.SaveChanges();
     return true;
 }
 private bool RemoveSelectedGameTranslation(IntegrationGameViewModel game)
 {
     var gameEntity = ValidateGetIntegrationGameDetailById(game.IntegrationGameId);
     var gameFeatureEntity =
         RepositoryFactory.Context.IntegrationGameFeatures.Where(
             x => x.IntegrationGameDetail.Id == gameEntity.Id);
     if (!gameFeatureEntity.Any())
         throw new Exception(ThrowMessage.GameFeatureTranslationNotExists.ToString());
     int gameTranslationCount = 0;
     game.GameTranslations?.ForEach(x =>
     {
         if (x.HasTranslation)
             gameTranslationCount++;
     });
     RepositoryFactory.Context.IntegrationGameFeatures.RemoveRange(gameFeatureEntity);
     RepositoryFactory.Context.IntegrationGameDetails.Remove(gameEntity);
     if (gameTranslationCount == 1)//have only one translation , can delete main id for game . Safe is safe ...
     {
         var mainGameEntity =
             RepositoryFactory.Context.IntegrationGames.FirstOrDefault(x => x.Id == game.Id);
         if (mainGameEntity != null)
             //delete main game
             RepositoryFactory.Context.IntegrationGames.Remove(mainGameEntity);
     }
     RepositoryFactory.Context.SaveChanges();
     return true;
 }
 public bool RemoveIntegratiomGame(IntegrationGameViewModel game)
 {
     return game.TemporarySeveralTranslationDelete
         ? RemoveAllGameTranslation(game)
         : RemoveSelectedGameTranslation(game);
 }