public JsonResult<ResponseViewModel<bool>> PostRemoveVersion(VersionViewModel versionForDelete)
 {
     var response =
         ServiceExecutor.Execute(
             () => _versionService.ChooseTargetAndFunction(versionForDelete, false));
     return Json(response);
 }
Example #2
0
 public bool ChooseTargetAndFunction(VersionViewModel version, bool addOrRemove)
 {
     if (version.VersionTarget.Equals("language"))
         return addOrRemove ? AddLanguageVersion(version) : DeleteLanguageVersion(version);
     if (version.VersionTarget.Equals("integrationGame"))
         return addOrRemove ? AddIntegrationGameVersion(version) : DeleteIntegrationGameVersion(version);
     if (version.VersionTarget.Equals("jokeCategory"))
         return addOrRemove ? AddJokeCategoryVersion(version) : DeleteJokeCategoryVersion(version);
     if (version.VersionTarget.Equals("joke"))
         return addOrRemove ? AddJokeVersion(version) : DeleteJokeVersion(version);
     if (version.VersionTarget.Equals("gameFeature"))
         return addOrRemove ? AddGameFeatureVersion(version) : DeleteGameFeatureVersion(version);
     return false;
 }
Example #3
0
 private bool AddGameFeatureVersion(VersionViewModel gameFeatureVersion)
 {
     RepositoryFactory.Context.GameFeatureVersions.Add(new GameFeatureVersionDao
     {
         Version = gameFeatureVersion.VersionNumber,
         Language = GetLanguageById(gameFeatureVersion.LanguageId)
     });
     RepositoryFactory.Context.SaveChanges();
     return true;
 }
Example #4
0
 private bool DeleteLanguageVersion(VersionViewModel versionForDelete)
 {
     var entityToDelete =
         RepositoryFactory.Context.LanguageVersions.FirstOrDefault(
             x =>
                 x.Language.Id.Equals(versionForDelete.LanguageId) &&
                 x.Version.Equals(versionForDelete.VersionNumber));
     if (entityToDelete == null)
         return false;
     RepositoryFactory.Context.LanguageVersions.Remove(entityToDelete);
     RepositoryFactory.Context.SaveChanges();
     return true;
 }
Example #5
0
 private bool AddLanguageVersion(VersionViewModel languageVersion)
 {
     RepositoryFactory.Context.LanguageVersions.Add(new LanguageVersionDao
     {
         NumberOfItemsInFileLanguage = languageVersion.NumberOf,
         Version = languageVersion.VersionNumber,
         Language = GetLanguageById(languageVersion.LanguageId)
     });
     RepositoryFactory.Context.SaveChanges();
     return true;
 }
Example #6
0
 private bool AddJokeVersion(VersionViewModel jokeVersion)
 {
     RepositoryFactory.Context.JokeVersions.Add(new JokeVersionDao
     {
         NumberOfJokes = jokeVersion.NumberOf,
         Version = jokeVersion.VersionNumber,
         Language = GetLanguageById(jokeVersion.LanguageId)
     });
     RepositoryFactory.Context.SaveChanges();
     return true;
 }
Example #7
0
 private bool AddIntegrationGameVersion(VersionViewModel integrationGameVersion)
 {
     RepositoryFactory.Context.IntegrationGameVersions.Add(new IntegrationGameVersionDao
     {
         NumberOfIntegrationGames = integrationGameVersion.NumberOf,
         Version = integrationGameVersion.VersionNumber,
         Language = GetLanguageById(integrationGameVersion.LanguageId)
     });
     RepositoryFactory.Context.SaveChanges();
     return true;
 }
 public JsonResult<ResponseViewModel<bool>> PostNewVersion(VersionViewModel newVersion)
 {
     var response =
         ServiceExecutor.Execute(() => _versionService.ChooseTargetAndFunction(newVersion, true));
     return Json(response);
 }