static void Main(string[] args) { var environment = args[0]; var connString = args[1]; var dbOptionsBuilder = new DbContextOptionsBuilder <CallCheatOnlineContext>(); dbOptionsBuilder.UseSqlServer(connString); var dbContext = new CallCheatOnlineContext(dbOptionsBuilder.Options); var appSettingItemRepository = new AppSettingItemRepository(dbContext); var appSettingProgramRepository = new AppSettingProgramRepository(dbContext); var programs = appSettingProgramRepository.GetAppSettingPrograms(); foreach (var program in programs) { if (File.Exists(program.AppConfigFilePath)) { File.Delete(program.AppConfigFilePath); } var programAppSettingItems = appSettingItemRepository.GetAppSettingItemsByProgramIDAndEnvironment(program.AppSettingProgramID, environment); var appSettingsKeyValuePairs = new Dictionary <string, string>(); foreach (var programAppSettingItem in programAppSettingItems) { appSettingsKeyValuePairs.Add(programAppSettingItem.Key, programAppSettingItem.Value); } using (var fileStream = File.Create(program.AppConfigFilePath)) { using (var streamWriter = new StreamWriter(fileStream)) { streamWriter.WriteLine("<configuration><appSettings>"); foreach (var appSettingItem in programAppSettingItems) { streamWriter.WriteLine($"<add key=\"{appSettingItem.Key}\" value=\"{appSettingItem.Value}\" />"); } streamWriter.WriteLine("</appSettings></configuration>"); } } } }
public Task UpdateGameScores(List <ClaimsPrincipal> userRankings, List <int> rankingScores) { return(Task.Run(() => { using (var db = new CallCheatOnlineContext()) { for (int i = 0; i < userRankings.Count; i++) { var gameUserID = db .UserLogin .Where((v) => v.UserLoginID == userRankings.ElementAt(i).GetUserLoginID()) .First() .GameUserID; var gameUser = db .GameUser .Where((v) => v.GameUserID == gameUserID) .FirstOrDefault(); gameUser.GameScore = gameUser.GameScore + rankingScores.ElementAt(i); db.SaveChanges(); } } })); }
public ForumThreadRepository(CallCheatOnlineContext context) { this.context = context; }
public AppSettingItemRepository(CallCheatOnlineContext context) { this.context = context; }
public AppExceptionRepository(CallCheatOnlineContext context) { this.context = context; }
public ForumUserRepository(CallCheatOnlineContext dbContext) { this.dbContext = dbContext; }
public UserLoginRepository(CallCheatOnlineContext dbContext, ForumUserRepository forumUserRepository, GameUserRepository gameUserRepository) { this.dbContext = dbContext; this.forumUserRepository = forumUserRepository; this.gameUserRepository = gameUserRepository; }