public JsonResult CopyProdData() { var dbhTo = new Db(Environment.Staging).Dbh; var dbhFrom = new Db().Dbh; var allMatches = dbhFrom.GetCollection<Match>("Matches").FindAll(); var allPlayers = dbhFrom.GetCollection<Player>("Players").FindAll(); var destinationMatches = dbhTo.GetCollection<Match>("Matches"); var destinationPlayers = dbhTo.GetCollection<Player>("Players"); destinationMatches.RemoveAll(); destinationPlayers.RemoveAll(); foreach (var match in allMatches) { destinationMatches.Save(match); } foreach (var player in allPlayers) { destinationPlayers.Save(player); } return Json(new { success = true }); }
public static void InitalizeConfig() { var environment = GetEnvironment(); var configCollection = new Db(environment).Dbh.GetCollection<Config>("Config"); var config = configCollection.FindOne(); if (config == null) { config = new Config(); configCollection.Save(config); } }