Код: Выделить всё
NewClient.cshtml:
@using Ecommerce.Models
@model NewClientViewModel
@using Microsoft.AspNetCore.Identity
@using Ecommerce.ViewModel
New Client creation
Email
First Name
Last Name
Password
Branch Name
Phone Number
Address
If Address same as Shipping Address please check box here
Shipping Address
Create Client
Код: Выделить всё
NewClientViewModel:
[Required]
public string Email { get; set; }
[Required]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Required]
[Display(Name = "Last Name")]
public string LastName { get; set;}
[Required]
public string Password { get; set; }
[Required]
[Display(Name = "Branch Name")]
public string BranchName { get; set; }
[Required]
[Display(Name = "Phone Number")]
public string PhoneNumber { get; set; }
[Required]
public string Address { get; set; }
[AllowNull]
[Display(Name = "Shipping Address")]
public string? ShippingAddress { get; set; }
public bool CheckedBox { get; set; } = false;
Код: Выделить всё
Client.cs:
public class Client
{
public int Id { get; set; }
public string BranchName { get; set; }
public string PhoneNumber { get; set; }
public string Address { get; set; }
[AllowNull] //
Подробнее здесь: [url]https://stackoverflow.com/questions/78991991/asp-net-core-8-mvc-view-model-validations[/url]
Мобильная версия