-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
aaron.allen
authored and
aaron.allen
committed
Nov 14, 2023
1 parent
ef435e8
commit 0fc2637
Showing
6 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@page "/CreateKit" | ||
@inject ILogger<CreateKit> Logger | ||
@using Microsoft.EntityFrameworkCore; | ||
@using MythicalToyMachine.Data | ||
@inject IDbContextFactory<PostgresContext> dbcontext | ||
|
||
<EditForm Model="@Model" OnSubmit="@Submit"> | ||
<InputText @bind-Value="Model!.Kitname" /> | ||
<InputFile OnChange="@LoadPick"/> | ||
<button type="submit">Submit</button> | ||
|
||
</EditForm> | ||
|
||
@code { | ||
public Kit Model { get; set; } = new Kit(); | ||
private bool cannotSavePick = false; | ||
|
||
protected override void OnInitialized() => Model ??= new(); | ||
|
||
private void Submit() | ||
{ | ||
Logger.LogInformation("Model.Id = {Id}", Model.Id); | ||
} | ||
|
||
private async Task LoadPick(InputFileChangeEventArgs e) | ||
{ | ||
var filetype = e.GetType; | ||
try{ | ||
if (Model.Kitname is null) | ||
{ | ||
Model.Kitname = Model.Id.ToString(); | ||
} | ||
//Model.Kitname = Model.Kitname.Replace(" ", ""); | ||
var path = $"wwwroot/Images/{Model.Kitname.Replace(" ", "") + Model.Id}.jpg"; | ||
await using FileStream fs = new(path, FileMode.Create); | ||
await e.File.OpenReadStream().CopyToAsync(fs); //maxfilesize | ||
} | ||
catch (Exception ex) | ||
{ | ||
cannotSavePick = true; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,9 @@ | |
<span class="oi oi-cart" aria-hidden="true"></span> Shopping Cart | ||
</NavLink> | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
|
||
<style> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.