28 lines
847 B
C#
28 lines
847 B
C#
using System.Collections.ObjectModel;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using StarsAssistant.Model;
|
|
|
|
namespace StarsAssistant.ViewModels;
|
|
|
|
public partial class PlanetViewModel(Planet planet) : ViewModelBase
|
|
{
|
|
public static ObservableCollection<PlanetViewModel> LoadAll() {
|
|
var context = new StarsDatabase("stars.sqlite");
|
|
var result = new ObservableCollection<PlanetViewModel>();
|
|
foreach (Planet planet in context.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;
|
|
}
|