Exemplo n.º 1
0
 public void ReceiveStation(PowerStation powerStation)
 {
     if (PowerStations.Count == MaxPowerStations)
     {
         DiscardPowerStation();
     }
     PowerStations.Add(powerStation);
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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"));
        }
Exemplo n.º 5
0
 public int GetBiggestPowerStation()
 {
     return(PowerStations.OrderByDescending(p => p.Value).FirstOrDefault()?.Value ?? 0);
 }