Refactoring Services (#61)
* Refactoring ViewModels into Razor Pages models * Cleaning up Basket viewcomponent * Refactoring services. Fixed bug in basket item counter.
This commit is contained in:
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.eShopWeb.RazorPages.ViewModels;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Infrastructure.Identity;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Microsoft.eShopWeb.RazorPages.Pages.Account
|
||||
{
|
||||
@@ -23,6 +24,24 @@ namespace Microsoft.eShopWeb.RazorPages.Pages.Account
|
||||
[BindProperty]
|
||||
public RegisterViewModel UserDetails { get; set; }
|
||||
|
||||
public class RegisterViewModel
|
||||
{
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
[Display(Name = "Email")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Password")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Confirm password")]
|
||||
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPost(string returnUrl = "/Index")
|
||||
{
|
||||
@@ -38,7 +57,6 @@ namespace Microsoft.eShopWeb.RazorPages.Pages.Account
|
||||
AddErrors(result);
|
||||
}
|
||||
return Page();
|
||||
|
||||
}
|
||||
|
||||
private void AddErrors(IdentityResult result)
|
||||
@@ -48,6 +66,5 @@ namespace Microsoft.eShopWeb.RazorPages.Pages.Account
|
||||
ModelState.AddModelError("", error.Description);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.eShopWeb.RazorPages.ViewModels;
|
||||
using Microsoft.eShopWeb.RazorPages.Interfaces;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Infrastructure.Identity;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ApplicationCore.Interfaces;
|
||||
|
||||
namespace Microsoft.eShopWeb.RazorPages.Pages.Account
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user