Business Layer
Refrence to DAL,MAL
Packages Null
Create a null IAccount and inherit it on Implementation
Data Layer
Refrence to MAL
Packages Microsoft.EntityFrameworkCore,SqlServer,Tools
Create a null IAccount and inherit it on Implementation
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using ModelLayer;
Class AppDataContext:-
namespace DataLayer
{
public class AppDataContext: IdentityDbContext<UserModel>
{
public AppDataContext(DbContextOptions<AppDataContext> options) : base(options) { }
}
}
Model Layer
Refrence to Null
Packages Microsoft.EntityFrameworkCore.Identity.EntityFrameworkCore,Microsoft.EntityFrameworkCore
Class:- UserModel
using Microsoft.AspNetCore.Identity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ModelLayer
{
public class UserModel: IdentityUser
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Email { get; set; }
[Required]
public string Password { get; set; }
}
}
UI Layer
Refrence to BAL,MAL
Packages Microsoft.EntityFrameworkCore.Identity.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Design
"ConnectionStrings": {
"DefaultConnection": "Data Source=DESKTOP-HH2RS6T\\SQLEXPRESS;Initial Catalog=ThinkAppDB;Integrated Security=True; TrustServerCertificate=true;"
}
Program.cs
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddDbContext<AppDataContext>(option =>
{
option.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
builder.Services.AddScoped<IAcount, Implementation>();
var app = builder.Build();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form</title>
</head>
<body>
<h2>Registration Form</h2>
<form action="#" method="post">
<label for="gender">Gender:</label><br>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label><br>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label><br>
<input type="radio" id="other" name="gender" value="other">
<label for="other">Other</label><br><br>
<label for="city">City:</label><br>
<select id="city" name="city">
<option value="New York">New York</option>
<option value="Los Angeles">Los Angeles</option>
<option value="Chicago">Chicago</option>
<option value="Houston">Houston</option>
<option value="Phoenix">Phoenix</option>
<option value="Philadelphia">Philadelphia</option>
</select><br><br>
<label for="classes">Classes:</label><br>
<input type="checkbox" id="math" name="classes" value="math">
<label for="math">Math</label><br>
<input type="checkbox" id="science" name="classes" value="science">
<label for="science">Science</label><br>
<input type="checkbox" id="history" name="classes" value="history">
<label for="history">History</label><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Comments
Post a Comment