You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
using Blazored.LocalStorage;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components;
|
|
using HeartTrack.Models;
|
|
using HeartTrack.Services;
|
|
|
|
namespace HeartTrack.Pages
|
|
{
|
|
public partial class AddTicket
|
|
{
|
|
|
|
[Inject]
|
|
public ILocalStorageService LocalStorage { get; set; }
|
|
|
|
[Inject]
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
[Inject]
|
|
public IWebHostEnvironment WebHostEnvironment { get; set; }
|
|
|
|
/// <summary>
|
|
/// The current item model
|
|
/// </summary>
|
|
public TicketModel ticketModel = new(){};
|
|
|
|
private async void HandleValidSubmit()
|
|
{
|
|
// Get the current data
|
|
var currentData = await LocalStorage.GetItemAsync<List<Ticket>>("data");
|
|
|
|
// Simulate the Id
|
|
ticketModel.Id = currentData.Max(s => s.Id) + 1;
|
|
|
|
// Add the item to the current data
|
|
currentData.Add(new Ticket
|
|
{
|
|
Id = ticketModel.Id,
|
|
Username = ticketModel.Username,
|
|
Contexte = ticketModel.Contexte,
|
|
Description = ticketModel.Description/*,
|
|
Urgence = ticketModel.Urgence*/
|
|
});
|
|
|
|
// Save the data
|
|
await LocalStorage.SetItemAsync("data", currentData);
|
|
|
|
NavigationManager.NavigateTo("tickets");
|
|
}
|
|
|
|
}
|
|
}
|