CRUD CustomDescriptions
parent
f9deadb7e0
commit
cb97427af3
@ -0,0 +1,62 @@
|
||||
@page "/CustomDescriptions/Add"
|
||||
|
||||
@using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
@using Gremlin_BlazorServer.Services;
|
||||
|
||||
@inject CustomDescriptionService customDescriptionService
|
||||
@inject NavigationManager navigationManager
|
||||
|
||||
<h2>Add CustomDescription</h2>
|
||||
<hr />
|
||||
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label for="CustomDescriptionId" class="control-label">CustomDescriptionId</label>
|
||||
<input form="CustomDescriptionId" class="form-control" @bind="@customDescription.CustomDescriptionId" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ProductNumber" class="control-label">ProductNumber</label>
|
||||
<input form="ProductNumber" class="form-control" @bind="@customDescription.ProductNumber" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="OptionNumber" class="control-label">OptionNumber</label>
|
||||
<input form="OptionNumber" class="form-control" @bind="@customDescription.OptionNumber" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Heading" class="control-label">Heading</label>
|
||||
<input form="Heading" class="form-control" @bind="@customDescription.Heading" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="DescriptionText" class="control-label">DescriptionText</label>
|
||||
<input form="DescriptionText" class="form-control" @bind="@customDescription.DescriptionText" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<input type="button" class="btn btn-primary" @onclick="@CreateCustomDescription" value="Save"/>
|
||||
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
CustomDescription customDescription = new CustomDescription();
|
||||
|
||||
protected async void CreateCustomDescription()
|
||||
{
|
||||
customDescription.DataModificationByUser = "Gremlin_BlazorServer";
|
||||
|
||||
if (await customDescriptionService.InsertCustomDescriptionAsync(customDescription))
|
||||
{
|
||||
navigationManager.NavigateTo("CustomDescriptions/Index");
|
||||
}
|
||||
}
|
||||
|
||||
void Cancel() => navigationManager.NavigateTo("CustomDescriptions/Index");
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
@page "/CustomDescriptions/Delete/{CustomDescriptionId}"
|
||||
|
||||
@using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
@using Gremlin_BlazorServer.Services;
|
||||
|
||||
@inject CustomDescriptionService customDescriptionService
|
||||
@inject NavigationManager navigationManager
|
||||
|
||||
<h2>Delete Employee</h2>
|
||||
<hr />
|
||||
<h3>Are you sure want to delete this?</h3>
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class=" col-md-8">
|
||||
<div class="form-group">
|
||||
<label>CustomDescriptionId:</label>
|
||||
<label>@customDescription.CustomDescriptionId</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>ProductNumber:</label>
|
||||
<label>@customDescription.ProductNumber</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>OptionNumber:</label>
|
||||
<label>@customDescription.OptionNumber</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Heading:</label>
|
||||
<label>@customDescription.Heading</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>DescriptionText:</label>
|
||||
<label>@customDescription.DescriptionText</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<input type="button" class="btn btn-danger" @onclick="@DeleteCustomDescription" value="Delete" />
|
||||
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string customDescriptionId { get; set; } = default!;
|
||||
CustomDescription? customDescription = new CustomDescription();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
customDescription = await Task.Run(() => customDescriptionService.GetCustomDescriptionAsync(Convert.ToUInt32(customDescriptionId)));
|
||||
}
|
||||
protected async void DeleteCustomDescription()
|
||||
{
|
||||
await customDescriptionService.DeleteCustomDescriptionAsync(customDescription);
|
||||
navigationManager.NavigateTo("CustomDescriptions/Index");
|
||||
}
|
||||
void Cancel()
|
||||
{
|
||||
navigationManager.NavigateTo("CustomDescriptions/Index");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
@page "/CustomDescriptions/Edit/{CustomDescriptionId}"
|
||||
|
||||
@using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
@using Gremlin_BlazorServer.Services;
|
||||
|
||||
@inject CustomDescriptionService customDescriptionservice
|
||||
@inject NavigationManager navigationManager
|
||||
|
||||
<h2>Edit CustomDescription</h2>
|
||||
<hr />
|
||||
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label for="CustomDescriptionId" class="control-label">CustomDescriptionId</label>
|
||||
<input form="CustomDescriptionId" class="form-control" @bind="@customDescription.CustomDescriptionId" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="CustomDescriptionId" class="control-label">CustomDescriptionId</label>
|
||||
<input form="CustomDescriptionId" class="form-control" @bind="@customDescription.CustomDescriptionId" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ProductNumber" class="control-label">ProductNumber</label>
|
||||
<input form="ProductNumber" class="form-control" @bind="@customDescription.ProductNumber" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="OptionNumber" class="control-label">OptionNumber</label>
|
||||
<input form="OptionNumber" class="form-control" @bind="@customDescription.OptionNumber" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Heading" class="control-label">Heading</label>
|
||||
<input form="Heading" class="form-control" @bind="@customDescription.Heading" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="DescriptionText" class="control-label">DescriptionText</label>
|
||||
<input form="DescriptionText" class="form-control" @bind="@customDescription.DescriptionText" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<input type="button" class="btn btn-primary" @onclick="@UpdateCustomDescription" value="Update" />
|
||||
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string? customDescriptionId { get; set; }
|
||||
CustomDescription? customDescription = new CustomDescription();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
customDescription = await Task.Run(() => customDescriptionservice.GetCustomDescriptionAsync(Convert.ToUInt32(customDescriptionId)));
|
||||
}
|
||||
|
||||
protected async void UpdateCustomDescription()
|
||||
{
|
||||
customDescription.DataModificationByUser = "Gremlin_BlazorServer";
|
||||
customDescription.DataModificationDate = DateTime.Now;
|
||||
customDescription.DataVersionNumber++;
|
||||
await customDescriptionservice.UpdateCustomDescriptionAsync(customDescription);
|
||||
navigationManager.NavigateTo("CustomDescriptions/Index");
|
||||
}
|
||||
|
||||
void Cancel() => navigationManager.NavigateTo("CustomDescriptions/Index");
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
@page "/CustomDescriptions/Index"
|
||||
|
||||
@using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
@using Gremlin_BlazorServer.Services;
|
||||
|
||||
@inject CustomDescriptionService customDescriptionservice
|
||||
|
||||
<h1>CustomDescriptions</h1>
|
||||
|
||||
<div class="text-center bg-blue-100">
|
||||
<input class="border-4 w-1/3 rounded m-6 p-6 h-8
|
||||
border-blue-300" @bind-value="searchCustomDescription"
|
||||
@bind-value:event="oninput" placeholder="Search by ProductNumber"
|
||||
@onchange="SearchCustomDescription_OnChange"/>
|
||||
</div>
|
||||
|
||||
<NavLink class="nav-link" href="CustomDescriptions/Add">
|
||||
<span class="oi oi-plus" aria-hidden="true">Add New CustomDescription</span>
|
||||
</NavLink>
|
||||
|
||||
|
||||
@if (allCustomDescriptions is null)
|
||||
{
|
||||
<p><em>Loading... !</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Es wurden @filteredCustomDescriptions.Count CustomDescriptions gefunden.</p>
|
||||
@if (allCustomDescriptions != null)
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@nameof(CustomDescription.CustomDescriptionId)</th>
|
||||
<th>@nameof(CustomDescription.ProductNumber)</th>
|
||||
<th>@nameof(CustomDescription.OptionNumber)</th>
|
||||
<th>@nameof(CustomDescription.Heading)</th>
|
||||
<th>@nameof(CustomDescription.DescriptionText)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (CustomDescription customDescription in filteredCustomDescriptions)
|
||||
{<tr>
|
||||
<td>@customDescription.CustomDescriptionId</td>
|
||||
<td>@customDescription.ProductNumber</td>
|
||||
<td>@customDescription.OptionNumber</td>
|
||||
<td>@customDescription.Heading</td>
|
||||
<td>@customDescription.DescriptionText</td>
|
||||
<td>
|
||||
<a class="nav-link" href="CustomDescriptions/Edit/@customDescription.CustomDescriptionId">
|
||||
<span class="oi oi-pencil" aria-hidden="true">Edit</span>
|
||||
</a>
|
||||
<a class="nav-link" href="CustomDescriptions/Delete/@customDescription.CustomDescriptionId">
|
||||
<span class="oi oi-trash" aria-hidden="true">Delete</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
public string searchCustomDescription = "";
|
||||
List<CustomDescription> allCustomDescriptions = new();
|
||||
List<CustomDescription> filteredCustomDescriptions = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
allCustomDescriptions = await Task.Run(() => customDescriptionservice.GetAllCustomDescriptionsAsync());
|
||||
filteredCustomDescriptions = allCustomDescriptions;
|
||||
}
|
||||
|
||||
private void SearchCustomDescription_OnChange()
|
||||
{
|
||||
filteredCustomDescriptions = allCustomDescriptions.Where(cD => cD.ProductNumber.ToLower().Contains(searchCustomDescription.ToLower())).ToList();
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,37 @@
|
||||
@page "/"
|
||||
@using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
@using Gremlin_BlazorServer.Services;
|
||||
|
||||
<PageTitle>Index</PageTitle>
|
||||
@inject LoginService loginService
|
||||
|
||||
<h1>Herzlich Willkommen bei Gremlin Blazor</h1>
|
||||
<PageTitle>Gremlin BlazorServer</PageTitle>
|
||||
|
||||
Dies ist die neue WebApp für Gremlin.
|
||||
<CascadingAuthenticationState>
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<h1>Hello, @registeredUser.UserName!</h1>
|
||||
<p>You can only see this content if you're authorized.</p>
|
||||
<button @onclick="SecureMethod">Authorized Only Button</button>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<h1>Welcome to Gremlin BlazorServer</h1>
|
||||
<h2>Authentication Failure!</h2>
|
||||
<p>You're not signed in.</p>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
</CascadingAuthenticationState>
|
||||
|
||||
@code {
|
||||
private RegisteredUser registeredUser = new();
|
||||
private bool IsAuthenticated { get; set; }
|
||||
|
||||
//protected async override Task OnInitializedAsync()
|
||||
//{
|
||||
// IsAuthenticated = await Task.Run(() => loginService.ValidateUserAsync(registeredUser));
|
||||
//}
|
||||
|
||||
private void SecureMethod()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
@page "/Login"
|
||||
|
||||
@using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
@using Gremlin_BlazorServer.Services;
|
||||
|
||||
@inject LoginService loginService
|
||||
|
||||
<h3>Login</h3>
|
||||
|
||||
<Container>
|
||||
<Row>
|
||||
<Column>
|
||||
<Tabs SelectedTab="@selectedTab" SelectedTabChanged="@OnSelectedTabChanged" Pills FullWidth>
|
||||
<Items>
|
||||
<Tab Name="login">Login</Tab>
|
||||
<Tab Name="register">Register</Tab>
|
||||
</Items>
|
||||
<Content>
|
||||
<TabPanel Name="login">
|
||||
<Card>
|
||||
<CardBody>
|
||||
<CardTitle>
|
||||
Welcome Back, Please Login.
|
||||
</CardTitle>
|
||||
</CardBody>
|
||||
<CardBody>
|
||||
<Validations @ref="@loginValidationsRef" Mode="ValidationMode.Manual" ValidateOnLoad="false">
|
||||
<Validation Validator="ValidationRule.IsNotEmpty">
|
||||
<Field>
|
||||
<FieldLabel>User Name</FieldLabel>
|
||||
<TextEdit @bind-Text="@userName" Placeholder="Enter user name...">
|
||||
<Feedback>
|
||||
<ValidationNone>Please Enter Your User Name. </ValidationNone>
|
||||
<ValidationSuccess>User Name is good</ValidationSuccess>
|
||||
<ValidationError>Please Enter A Valid User Name</ValidationError>
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</Field>
|
||||
</Validation>
|
||||
<Validation Validator="ValidationRule.IsNotEmpty">
|
||||
<Field>
|
||||
<FieldLabel>Password</FieldLabel>
|
||||
<TextEdit @bind-Text="password" Role="TextRole.Password" Placeholder="Enter Password..." />
|
||||
</Field>
|
||||
</Validation>
|
||||
<Field>
|
||||
<Check TValue="bool" @bind-Checked="@rememberMe">Remember Me</Check>
|
||||
</Field>
|
||||
</Validations>
|
||||
</CardBody>
|
||||
<CardBody>
|
||||
<Button Color="Color.Primary" Clicked="@OnLoginClicked">Login</Button>
|
||||
<Button Color="Color.Secondary">Forgot Password</Button>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</TabPanel>
|
||||
<TabPanel Name="register">
|
||||
<Card>
|
||||
<CardBody>
|
||||
<CardTitle>
|
||||
New Here? Create An Account
|
||||
</CardTitle>
|
||||
</CardBody>
|
||||
<CardBody>
|
||||
<Validations @ref="@registerValidationsRef" Mode="ValidationMode.Manual" ValidateOnLoad="false">
|
||||
<Validation Validator="ValidationRule.IsNotEmpty">
|
||||
<Field>
|
||||
<FieldLabel>Name</FieldLabel>
|
||||
<TextEdit @bind-Text="userName" Placeholder="Enter Your User Name" />
|
||||
</Field>
|
||||
</Validation>
|
||||
<Validation Validator="ValidationRule.IsNotEmpty">
|
||||
<Field>
|
||||
<FieldLabel>Password</FieldLabel>
|
||||
<TextEdit @bind-Text="password" Role="TextRole.Password" Placeholder="Enter Password" />
|
||||
<FieldHelp>Password Strength: <Text TextColor="TextColor.Danger">Strong</Text></FieldHelp>
|
||||
</Field>
|
||||
</Validation>
|
||||
</Validations>
|
||||
</CardBody>
|
||||
<CardBody>
|
||||
<Button Color="Color.Primary" Clicked="@OnRegisterClicked">
|
||||
Create Account
|
||||
</Button>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</TabPanel>
|
||||
</Content>
|
||||
</Tabs>
|
||||
</Column>
|
||||
</Row>
|
||||
</Container>
|
||||
|
||||
@code {
|
||||
Validations loginValidationsRef = new();
|
||||
Validations registerValidationsRef = new();
|
||||
|
||||
private RegisteredUser registeredUser = new();
|
||||
|
||||
private string selectedTab = "login";
|
||||
private string userName = "";
|
||||
private string password = "";
|
||||
private bool rememberMe = false;
|
||||
|
||||
private Task OnSelectedTabChanged(string name)
|
||||
{
|
||||
selectedTab = name;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task OnLoginClicked()
|
||||
{
|
||||
if (await loginValidationsRef.ValidateAll())
|
||||
{
|
||||
RegisteredUser registeredUser = new()
|
||||
{
|
||||
UserName = userName,
|
||||
PasswordHash = password
|
||||
};
|
||||
|
||||
bool IsValidated = await Task.Run(() => loginService.ValidateUserAsync(registeredUser));
|
||||
await loginValidationsRef.ClearAll();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnRegisterClicked()
|
||||
{
|
||||
if (await registerValidationsRef.ValidateAll())
|
||||
{
|
||||
registeredUser.UserName = userName;
|
||||
registeredUser.PasswordHash = password;
|
||||
|
||||
_ = await Task.Run(() => loginService.InsertRegisteredUserAsync(registeredUser));
|
||||
|
||||
await registerValidationsRef.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue