public void ReceiveStation(PowerStation powerStation) { if (PowerStations.Count == MaxPowerStations) { DiscardPowerStation(); } PowerStations.Add(powerStation); }
public int CalculateIncome() { var orderedPowerStations = PowerStations.OrderByDescending(p => p.Power); List <PowerStation> stationsThatCanBePowered = new List <PowerStation>(); foreach (var powerStation in PowerStations) { if (CanPower(powerStation)) { stationsThatCanBePowered.Add(powerStation); } } return(stationsThatCanBePowered.Sum(p => p.Power)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } PowerStations = await _context.PowerStations.FirstOrDefaultAsync(m => m.Id == id); if (PowerStations == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } PowerStations = await _context.PowerStations.FindAsync(id); if (PowerStations != null) { _context.PowerStations.Remove(PowerStations); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public int GetBiggestPowerStation() { return(PowerStations.OrderByDescending(p => p.Value).FirstOrDefault()?.Value ?? 0); }