Skip to content

Commit

Permalink
#218 - UI for registration screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Mar 7, 2019
1 parent ff7a6e8 commit 55fded0
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Money.UI.Blazor/Pages/Account/Register.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@page "/account/register"
@inherits RegisterBase

<Title Main="Register" Sub="Create a new account" />

<div class="login">

<ValidationSummary ErrorMessages="@ErrorMessages" />
<div class="row">
<div class="col-md-4">
<section>
<form onsubmit="@OnSubmitAsync">
<div class="form-group">
<label for="UserName">User name</label>
<input id="UserName" class="form-control" type="text" autofocus bind="@UserName" />
</div>
<div class="form-group">
<label for="Password">Password</label>
<input id="Password" class="form-control" type="password" bind="@Password" />
</div>
<div class="form-group">
<label for="ConfirmPassword">Confirm password</label>
<input id="ConfirmPassword" class="form-control" type="password" bind="@ConfirmPassword" />
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
</section>
</div>
</div>
</div>
50 changes: 50 additions & 0 deletions src/Money.UI.Blazor/Pages/Account/Register.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Microsoft.AspNetCore.Blazor.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Money.Pages
{
public class RegisterBase : BlazorComponent
{
public string UserName { get; set; }
public string Password { get; set; }
public string ConfirmPassword { get; set; }

public List<string> ErrorMessages { get; } = new List<string>();

protected Task OnSubmitAsync()
{
if (Validate())
{
UserName = null;
Password = null;
ConfirmPassword = null;

ErrorMessages.Add("Passed ;-)");
}

return Task.CompletedTask;
}

protected bool Validate()
{
ErrorMessages.Clear();

if (String.IsNullOrEmpty(UserName))
ErrorMessages.Add("Please, fill user name.");

if (String.IsNullOrEmpty(Password))
ErrorMessages.Add("Please, fill password.");

if (String.IsNullOrEmpty(ConfirmPassword))
ErrorMessages.Add("Please, fill password confirmation.");
else if (Password != ConfirmPassword)
ErrorMessages.Add("Password must match password confirmation.");

return ErrorMessages.Count == 0;
}
}
}

0 comments on commit 55fded0

Please sign in to comment.