2024-07-23 18:20:01 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2024-08-15 19:46:43 +00:00
|
|
|
|
using StarsAssistant.Model;
|
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
|
|
|
|
|
{
|
|
|
|
|
public static ObservableCollection<PlanetViewModel> LoadAll() {
|
|
|
|
|
var context = new StarsDatabase("stars.sqlite");
|
|
|
|
|
var result = new ObservableCollection<PlanetViewModel>();
|
|
|
|
|
foreach (Planet planet in context.Planets.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.Owner ?? String.Empty;
|
|
|
|
|
|
|
|
|
|
public int Value => planet.Value ?? 0;
|
|
|
|
|
}
|