2024-07-23 18:20:01 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2024-08-18 17:21:18 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-08-15 19:46:43 +00:00
|
|
|
|
using StarsAssistant.Model;
|
2024-09-11 18:04:20 +00:00
|
|
|
|
using Splat;
|
2024-07-23 18:20:01 +00:00
|
|
|
|
|
2024-08-15 19:46:43 +00:00
|
|
|
|
namespace StarsAssistant.ViewModels;
|
2024-07-23 18:20:01 +00:00
|
|
|
|
|
|
|
|
|
public partial class PlanetViewModel(Planet planet) : ViewModelBase
|
|
|
|
|
{
|
2024-09-15 20:10:44 +00:00
|
|
|
|
public static ObservableCollection<PlanetViewModel> LoadAll()
|
|
|
|
|
{
|
2024-09-11 18:04:20 +00:00
|
|
|
|
using var db = Locator.Current.GetService<StarsDatabase>()!;
|
2024-07-23 18:20:01 +00:00
|
|
|
|
var result = new ObservableCollection<PlanetViewModel>();
|
2024-09-11 18:04:20 +00:00
|
|
|
|
foreach (Planet planet in db.Planet.Where(p => p.OwnerId == "Atlantis").ToList())
|
2024-07-23 18:20:01 +00:00
|
|
|
|
{
|
|
|
|
|
var vm = new PlanetViewModel(planet);
|
|
|
|
|
result.Add(vm);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly Planet planet = planet;
|
|
|
|
|
|
|
|
|
|
public string Name => planet.Name;
|
|
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
|
public string Owner => planet.OwnerId ?? String.Empty;
|
2024-07-23 18:20:01 +00:00
|
|
|
|
|
|
|
|
|
public int Value => planet.Value ?? 0;
|
2024-09-11 18:04:20 +00:00
|
|
|
|
|
|
|
|
|
public int Population => planet.Population ?? 0;
|
|
|
|
|
|
|
|
|
|
public int SurfaceIronium => planet.SurfaceIronium ?? 0;
|
|
|
|
|
|
|
|
|
|
public int SurfaceBoranium => planet.SurfaceBoranium ?? 0;
|
|
|
|
|
|
|
|
|
|
public int SurfaceGermanium => planet.SurfaceGermanium ?? 0;
|
2024-07-23 18:20:01 +00:00
|
|
|
|
}
|