public void EndMiningFleet([FromBody] Models.MiningFleet fleet) { var apiToken = Request.Cookies["APIToken"]; //var user = DataAccess.User.SelectUserByAPIToken(apiToken); //Set IsActive to 0 on the mining fleet DataAccess.Fleet.EndMiningFleet(fleet.MiningFleetKey); //Loop through the mining fleet members and calculate the differences of the mining ledger and calculate the difference and put that as the 'ending' mining fleet ledger //DataAccess.MiningLedger.InsertEndingFleetMiningLedger(fleet.MiningFleetKey); DataAccess.MiningLedger.InsertPendingMiningFleetLedger(fleet.MiningFleetKey); }
public static int InsertMiningFleet(Models.MiningFleet fleet) { using (var conn = ConnectionFactory()) { conn.Open(); return(conn.QuerySingle <int>( @"INSERT INTO MiningFleets (FleetBossKey, StartTime, EndTime, IsActive) VALUES (@FleetBossKey, @StartTime, @EndTime, @IsActive) RETURNING MiningFleetKey;", new { FleetBossKey = fleet.FleetBossKey, StartTime = fleet.StartTime.ToUniversalTime(), EndTime = fleet.EndTime, IsActive = fleet.IsActive })); } }
public void CreateMiningFleet() { var user = DataAccess.User.SelectUserByAPIToken(Request.Cookies["APIToken"]); var fleet = new Models.MiningFleet { FleetBossKey = user.UserKey, StartTime = DateTime.Now, EndTime = DateTime.MaxValue, IsActive = true }; fleet.MiningFleetKey = DataAccess.Fleet.InsertMiningFleet(fleet); DataAccess.Fleet.InsertMiningFleetMember(user.UserKey, fleet.MiningFleetKey); DataAccess.MiningLedger.InsertStartingFleetMiningLedger(user.UserKey, fleet.MiningFleetKey); }