38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Collections.ObjectModel;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using StarsAssistant.Model;
|
|
using Splat;
|
|
|
|
namespace StarsAssistant.ViewModels;
|
|
|
|
public partial class PlanetViewModel(Planet planet) : ViewModelBase
|
|
{
|
|
public static ObservableCollection<PlanetViewModel> LoadAll()
|
|
{
|
|
using var db = Locator.Current.GetService<StarsDatabase>()!;
|
|
var result = new ObservableCollection<PlanetViewModel>();
|
|
foreach (Planet planet in db.Planet.Where(p => p.OwnerId == "Atlantis").ToList())
|
|
{
|
|
var vm = new PlanetViewModel(planet);
|
|
result.Add(vm);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private readonly Planet planet = planet;
|
|
|
|
public string Name => planet.Name;
|
|
|
|
public string Owner => planet.OwnerId ?? String.Empty;
|
|
|
|
public int Value => planet.Value ?? 0;
|
|
|
|
public int Population => planet.Population ?? 0;
|
|
|
|
public int SurfaceIronium => planet.SurfaceIronium ?? 0;
|
|
|
|
public int SurfaceBoranium => planet.SurfaceBoranium ?? 0;
|
|
|
|
public int SurfaceGermanium => planet.SurfaceGermanium ?? 0;
|
|
}
|