Reading vehicles from database
This commit is contained in:
parent
6fad49e260
commit
5f6b71b0bd
@ -5,6 +5,7 @@
|
|||||||
xmlns:pages="clr-namespace:AutoCat.Pages"
|
xmlns:pages="clr-namespace:AutoCat.Pages"
|
||||||
xmlns:utils="using:AutoCat.Utils"
|
xmlns:utils="using:AutoCat.Utils"
|
||||||
xmlns:vm="using:AutoCat.ViewModels"
|
xmlns:vm="using:AutoCat.ViewModels"
|
||||||
|
xmlns:models="using:AutoCatCore.Model"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="AutoCat.Pages.HistoryPage"
|
x:Class="AutoCat.Pages.HistoryPage"
|
||||||
x:DataType="vm:HistoryViewModel"
|
x:DataType="vm:HistoryViewModel"
|
||||||
@ -19,6 +20,18 @@
|
|||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="300, Auto, *">
|
||||||
|
<ListBox ItemsSource="{Binding Vehicles}" Name="VehiclesList">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type models:Vehicle}">
|
||||||
|
<TextBlock Text="qwe"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<GridSplitter Grid.Column="1" ResizeDirection="Columns"/>
|
||||||
|
<pages:ReportPage Grid.Column="2" Vehicle="{Binding ElementName=VehiclesList, Path=SelectedItem, Mode=OneWay}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<Grid ColumnDefinitions="300, Auto, *">
|
<Grid ColumnDefinitions="300, Auto, *">
|
||||||
<ListBox ItemsSource="{Binding Vehicles}"
|
<ListBox ItemsSource="{Binding Vehicles}"
|
||||||
@ -28,4 +41,5 @@
|
|||||||
<pages:ReportPage Grid.Column="2" Vehicle="{Binding ElementName=VehiclesList, Path=SelectedItem, Mode=OneWay}"/>
|
<pages:ReportPage Grid.Column="2" Vehicle="{Binding ElementName=VehiclesList, Path=SelectedItem, Mode=OneWay}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutoCatCore.Model;
|
using AutoCatCore.Model;
|
||||||
using AutoCatCore.Services.Storage;
|
using AutoCatCore.Services.Storage;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace AutoCat.ViewModels;
|
namespace AutoCat.ViewModels;
|
||||||
|
|
||||||
@ -13,9 +16,17 @@ public class HistoryViewModel: ViewModelBase
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public ICollection<Vehicle> Vehicles { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public HistoryViewModel(IStorageService storageService)
|
public HistoryViewModel(IStorageService storageService)
|
||||||
{
|
{
|
||||||
_storageService = storageService;
|
_storageService = storageService;
|
||||||
|
Vehicles = storageService.GetVehicles();
|
||||||
|
this.RaisePropertyChanged(nameof(Vehicles));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddVehicle(Vehicle vehicle)
|
public async Task AddVehicle(Vehicle vehicle)
|
||||||
|
|||||||
@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
namespace AutoCatCore.Model
|
namespace AutoCatCore.Model
|
||||||
{
|
{
|
||||||
public class VehicleEvent
|
public class VehicleEvent(string id)
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
[MaxLength(50)]
|
||||||
|
public string Id { get; set; } = id;
|
||||||
|
|
||||||
public double? Date { get; set; }
|
public double? Date { get; set; }
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.Specialized;
|
||||||
using AutoCatCore.Model;
|
using AutoCatCore.Model;
|
||||||
|
|
||||||
namespace AutoCatCore.Services.Storage;
|
namespace AutoCatCore.Services.Storage;
|
||||||
@ -11,4 +12,6 @@ public interface IStorageService
|
|||||||
public Task SetUser(User user);
|
public Task SetUser(User user);
|
||||||
|
|
||||||
public Task AddVehicle(Vehicle vehicle);
|
public Task AddVehicle(Vehicle vehicle);
|
||||||
|
|
||||||
|
public ICollection<Vehicle> GetVehicles();
|
||||||
}
|
}
|
||||||
@ -42,8 +42,9 @@ public class StorageService: IStorageService
|
|||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T GetVehicles<T>() where T: INotifyCollectionChanged
|
public ICollection<Vehicle> GetVehicles()
|
||||||
{
|
{
|
||||||
|
_dbContext.Vehicles.Load();
|
||||||
return _dbContext.Vehicles.Local;
|
return _dbContext.Vehicles.Local;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user