Can now edit file info
This commit is contained in:
@@ -22,10 +22,32 @@ namespace ReceiptPDFBuilder.ViewModels;
|
||||
|
||||
class EditFileViewModel : BaseViewModel
|
||||
{
|
||||
ReportFile _file;
|
||||
ReportFile _clonedFile;
|
||||
ReportFile _originalFile;
|
||||
|
||||
public EditFileViewModel(ReportFile file, IChangeViewModel viewModelChanger) : base(viewModelChanger)
|
||||
{
|
||||
_file = file;
|
||||
_clonedFile = new ReportFile(file);
|
||||
_originalFile = file;
|
||||
}
|
||||
|
||||
public ReportFile OriginalFile
|
||||
{
|
||||
get => _originalFile;
|
||||
}
|
||||
|
||||
public ReportFile ClonedFile
|
||||
{
|
||||
get => _clonedFile;
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
DialogHost.Close("DialogHost", null);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
DialogHost.Close("DialogHost", ClonedFile);
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
||||
ReportFiles.Add(new ReportFile()
|
||||
{
|
||||
Title = Path.GetFileName(filePath),
|
||||
Date = DateOnly.FromDateTime(File.GetCreationTime(filePath)),
|
||||
ReceiptDateTime = File.GetCreationTime(filePath),
|
||||
Notes = "TEST NOTES",
|
||||
FilePath = filePath,
|
||||
});
|
||||
@@ -125,6 +125,12 @@ class MainViewModel : BaseViewModel, IFontResolver
|
||||
public async void EditFileProperties(ReportFile file)
|
||||
{
|
||||
var result = await DialogHost.Show(new EditFileViewModel(file, ViewModelChanger));
|
||||
if (result != null && result is ReportFile updatedData)
|
||||
{
|
||||
file.Title = updatedData.Title;
|
||||
file.ReceiptDateTime = updatedData.ReceiptDateTime;
|
||||
file.Notes = updatedData.Notes;
|
||||
}
|
||||
}
|
||||
|
||||
public async void BuildPDF()
|
||||
|
||||
Reference in New Issue
Block a user