using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Components; using ProjetBlazor.Services; using ProjetBlazor.Modeles; namespace ProjetBlazor.Pages { public partial class AddMusique { private MusiqueModel musiqueModel = new MusiqueModel(); [Inject] public IDataService DataService { get; set; } [Inject] public NavigationManager NavigationManager { get; set; } private async void HandleValidSubmit() { await DataService.Add(musiqueModel); NavigationManager.NavigateTo("MusiqueListe"); } private async Task LoadImage(InputFileChangeEventArgs e) { // Set the content of the image to the model using (var memoryStream = new MemoryStream()) { await e.File.OpenReadStream().CopyToAsync(memoryStream); musiqueModel.image = memoryStream.ToArray(); } } } }