Removed unsued properties from user controller index
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Data
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
optionsBuilder.UseSqlServer("Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;");
|
||||
optionsBuilder.UseSqlServer("Server=.;Database=RentACar;Integrated Security=true;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(RentACarDbContext))]
|
||||
[Migration("20220406212949_migrena1")]
|
||||
partial class migrena1
|
||||
[Migration("20220407201957_migrena")]
|
||||
partial class migrena
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ namespace Data.Migrations
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PersonalNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
@@ -152,20 +152,24 @@ namespace Data.Migrations
|
||||
.HasDatabaseName("UserNameIndex")
|
||||
.HasFilter("[NormalizedUserName] IS NOT NULL");
|
||||
|
||||
b.HasIndex("PersonalNumber")
|
||||
.IsUnique()
|
||||
.HasFilter("[PersonalNumber] IS NOT NULL");
|
||||
|
||||
b.ToTable("AspNetUsers");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = "8fb80b37-172b-4100-b499-cfa8b8bd225f",
|
||||
Id = "387f2544-bfa8-44ed-9793-a5bd5eaafe57",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "863ef77f-ca57-4cdc-8a69-2034d137775e",
|
||||
ConcurrencyStamp = "6fa96ce1-7e47-4f44-bdeb-e13705729bdb",
|
||||
Email = "admin@admin.admin",
|
||||
EmailConfirmed = false,
|
||||
LockoutEnabled = false,
|
||||
PasswordHash = "AQAAAAEAACcQAAAAEA2HtcFcKoyTZ8qyX/ACxeWR3uxNREHn09A1/5s+c2wzkUUOThsWUqEiv7Rn3vmgJQ==",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAECdhgDXw9WdaYvos/Ef9zaSiSApNswFCna2iNk8tu8BsvXRVMQWvdPLE1L8sTdgjDQ==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "670d518e-9966-41bb-ae76-3a8968513497",
|
||||
SecurityStamp = "db1ac172-eb3b-4b93-9f31-3f748a1eda84",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "admin"
|
||||
});
|
||||
@@ -200,14 +204,14 @@ namespace Data.Migrations
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = "6d92895f-aab5-46b6-8650-0d8c1b566372",
|
||||
ConcurrencyStamp = "372dca25-7ccc-4995-9b3f-32bfdebc1ff6",
|
||||
Id = "fb054f77-3578-45ee-a3d6-e6fe706526b2",
|
||||
ConcurrencyStamp = "4af0d06c-63be-448c-a1ee-7c369398dee5",
|
||||
Name = "Admin"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "b57865e0-539e-4f79-8215-103e22016c83",
|
||||
ConcurrencyStamp = "97e7c5da-d35b-475b-85cd-f5df914e5850",
|
||||
Id = "d3aa27bb-2866-4a7d-9f0d-30498859ae94",
|
||||
ConcurrencyStamp = "64b281d1-f963-43ae-a25e-1f8f220b553d",
|
||||
Name = "Employee"
|
||||
});
|
||||
});
|
||||
@@ -299,13 +303,13 @@ namespace Data.Migrations
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
UserId = "8fb80b37-172b-4100-b499-cfa8b8bd225f",
|
||||
RoleId = "6d92895f-aab5-46b6-8650-0d8c1b566372"
|
||||
UserId = "387f2544-bfa8-44ed-9793-a5bd5eaafe57",
|
||||
RoleId = "fb054f77-3578-45ee-a3d6-e6fe706526b2"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "8fb80b37-172b-4100-b499-cfa8b8bd225f",
|
||||
RoleId = "b57865e0-539e-4f79-8215-103e22016c83"
|
||||
UserId = "387f2544-bfa8-44ed-9793-a5bd5eaafe57",
|
||||
RoleId = "d3aa27bb-2866-4a7d-9f0d-30498859ae94"
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Data.Migrations
|
||||
{
|
||||
public partial class migrena1 : Migration
|
||||
public partial class migrena : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace Data.Migrations
|
||||
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
LastName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
PersonalNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
PersonalNumber = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
||||
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
@@ -204,27 +204,27 @@ namespace Data.Migrations
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetRoles",
|
||||
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
|
||||
values: new object[] { "6d92895f-aab5-46b6-8650-0d8c1b566372", "372dca25-7ccc-4995-9b3f-32bfdebc1ff6", "Admin", null });
|
||||
values: new object[] { "fb054f77-3578-45ee-a3d6-e6fe706526b2", "4af0d06c-63be-448c-a1ee-7c369398dee5", "Admin", null });
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetRoles",
|
||||
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
|
||||
values: new object[] { "b57865e0-539e-4f79-8215-103e22016c83", "97e7c5da-d35b-475b-85cd-f5df914e5850", "Employee", null });
|
||||
values: new object[] { "d3aa27bb-2866-4a7d-9f0d-30498859ae94", "64b281d1-f963-43ae-a25e-1f8f220b553d", "Employee", null });
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetUsers",
|
||||
columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "FirstName", "LastName", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PersonalNumber", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" },
|
||||
values: new object[] { "8fb80b37-172b-4100-b499-cfa8b8bd225f", 0, "863ef77f-ca57-4cdc-8a69-2034d137775e", "admin@admin.admin", false, null, null, false, null, null, null, "AQAAAAEAACcQAAAAEA2HtcFcKoyTZ8qyX/ACxeWR3uxNREHn09A1/5s+c2wzkUUOThsWUqEiv7Rn3vmgJQ==", null, null, false, "670d518e-9966-41bb-ae76-3a8968513497", false, "admin" });
|
||||
values: new object[] { "387f2544-bfa8-44ed-9793-a5bd5eaafe57", 0, "6fa96ce1-7e47-4f44-bdeb-e13705729bdb", "admin@admin.admin", false, null, null, false, null, null, null, "AQAAAAEAACcQAAAAECdhgDXw9WdaYvos/Ef9zaSiSApNswFCna2iNk8tu8BsvXRVMQWvdPLE1L8sTdgjDQ==", null, null, false, "db1ac172-eb3b-4b93-9f31-3f748a1eda84", false, "admin" });
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetUserRoles",
|
||||
columns: new[] { "RoleId", "UserId" },
|
||||
values: new object[] { "6d92895f-aab5-46b6-8650-0d8c1b566372", "8fb80b37-172b-4100-b499-cfa8b8bd225f" });
|
||||
values: new object[] { "fb054f77-3578-45ee-a3d6-e6fe706526b2", "387f2544-bfa8-44ed-9793-a5bd5eaafe57" });
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetUserRoles",
|
||||
columns: new[] { "RoleId", "UserId" },
|
||||
values: new object[] { "b57865e0-539e-4f79-8215-103e22016c83", "8fb80b37-172b-4100-b499-cfa8b8bd225f" });
|
||||
values: new object[] { "d3aa27bb-2866-4a7d-9f0d-30498859ae94", "387f2544-bfa8-44ed-9793-a5bd5eaafe57" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AspNetRoleClaims_RoleId",
|
||||
@@ -258,6 +258,13 @@ namespace Data.Migrations
|
||||
table: "AspNetUsers",
|
||||
column: "NormalizedEmail");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AspNetUsers_PersonalNumber",
|
||||
table: "AspNetUsers",
|
||||
column: "PersonalNumber",
|
||||
unique: true,
|
||||
filter: "[PersonalNumber] IS NOT NULL");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "UserNameIndex",
|
||||
table: "AspNetUsers",
|
||||
@@ -122,7 +122,7 @@ namespace Data.Migrations
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PersonalNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
@@ -150,20 +150,24 @@ namespace Data.Migrations
|
||||
.HasDatabaseName("UserNameIndex")
|
||||
.HasFilter("[NormalizedUserName] IS NOT NULL");
|
||||
|
||||
b.HasIndex("PersonalNumber")
|
||||
.IsUnique()
|
||||
.HasFilter("[PersonalNumber] IS NOT NULL");
|
||||
|
||||
b.ToTable("AspNetUsers");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = "8fb80b37-172b-4100-b499-cfa8b8bd225f",
|
||||
Id = "387f2544-bfa8-44ed-9793-a5bd5eaafe57",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "863ef77f-ca57-4cdc-8a69-2034d137775e",
|
||||
ConcurrencyStamp = "6fa96ce1-7e47-4f44-bdeb-e13705729bdb",
|
||||
Email = "admin@admin.admin",
|
||||
EmailConfirmed = false,
|
||||
LockoutEnabled = false,
|
||||
PasswordHash = "AQAAAAEAACcQAAAAEA2HtcFcKoyTZ8qyX/ACxeWR3uxNREHn09A1/5s+c2wzkUUOThsWUqEiv7Rn3vmgJQ==",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAECdhgDXw9WdaYvos/Ef9zaSiSApNswFCna2iNk8tu8BsvXRVMQWvdPLE1L8sTdgjDQ==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "670d518e-9966-41bb-ae76-3a8968513497",
|
||||
SecurityStamp = "db1ac172-eb3b-4b93-9f31-3f748a1eda84",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "admin"
|
||||
});
|
||||
@@ -198,14 +202,14 @@ namespace Data.Migrations
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = "6d92895f-aab5-46b6-8650-0d8c1b566372",
|
||||
ConcurrencyStamp = "372dca25-7ccc-4995-9b3f-32bfdebc1ff6",
|
||||
Id = "fb054f77-3578-45ee-a3d6-e6fe706526b2",
|
||||
ConcurrencyStamp = "4af0d06c-63be-448c-a1ee-7c369398dee5",
|
||||
Name = "Admin"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "b57865e0-539e-4f79-8215-103e22016c83",
|
||||
ConcurrencyStamp = "97e7c5da-d35b-475b-85cd-f5df914e5850",
|
||||
Id = "d3aa27bb-2866-4a7d-9f0d-30498859ae94",
|
||||
ConcurrencyStamp = "64b281d1-f963-43ae-a25e-1f8f220b553d",
|
||||
Name = "Employee"
|
||||
});
|
||||
});
|
||||
@@ -297,13 +301,13 @@ namespace Data.Migrations
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
UserId = "8fb80b37-172b-4100-b499-cfa8b8bd225f",
|
||||
RoleId = "6d92895f-aab5-46b6-8650-0d8c1b566372"
|
||||
UserId = "387f2544-bfa8-44ed-9793-a5bd5eaafe57",
|
||||
RoleId = "fb054f77-3578-45ee-a3d6-e6fe706526b2"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "8fb80b37-172b-4100-b499-cfa8b8bd225f",
|
||||
RoleId = "b57865e0-539e-4f79-8215-103e22016c83"
|
||||
UserId = "387f2544-bfa8-44ed-9793-a5bd5eaafe57",
|
||||
RoleId = "d3aa27bb-2866-4a7d-9f0d-30498859ae94"
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace WebApp.Areas.Identity.Pages.Account
|
||||
{
|
||||
@@ -23,16 +22,19 @@ namespace WebApp.Areas.Identity.Pages.Account
|
||||
{
|
||||
private readonly SignInManager<User> _signInManager;
|
||||
private readonly UserManager<User> _userManager;
|
||||
private readonly RoleManager<IdentityRole> _roleManager;
|
||||
private readonly ILogger<RegisterModel> _logger;
|
||||
private readonly IEmailSender _emailSender;
|
||||
|
||||
public RegisterModel(
|
||||
UserManager<User> userManager,
|
||||
SignInManager<User> signInManager,
|
||||
RoleManager<IdentityRole> roleManager,
|
||||
ILogger<RegisterModel> logger,
|
||||
IEmailSender emailSender)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_roleManager = roleManager;
|
||||
_signInManager = signInManager;
|
||||
_logger = logger;
|
||||
_emailSender = emailSender;
|
||||
@@ -57,13 +59,12 @@ namespace WebApp.Areas.Identity.Pages.Account
|
||||
[Display(Name = "Email")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Display(Name = "First name")]
|
||||
[Display(Name = "First Name")]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
[Display(Name = "Last name")]
|
||||
[Display(Name = "Last Name")]
|
||||
public string LastName { get; set; }
|
||||
|
||||
[Phone]
|
||||
[Display(Name = "Phone")]
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
@@ -98,6 +99,9 @@ namespace WebApp.Areas.Identity.Pages.Account
|
||||
var result = await _userManager.CreateAsync(user, Input.Password);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
var defaultrole = _roleManager.FindByIdAsync("d3aa27bb-2866-4a7d-9f0d-30498859ae94").Result;
|
||||
|
||||
await _userManager.AddToRoleAsync(user, defaultrole.Name);
|
||||
_logger.LogInformation("User created a new account with password.");
|
||||
|
||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace WebApp.Controllers
|
||||
|
||||
// GET: Cars/Edit/5
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Edit(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
@@ -90,6 +91,7 @@ namespace WebApp.Controllers
|
||||
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Edit(int id, [Bind("Id, Brand, Model, Year, CountPassengerSeats, Description, PriceForDay")] Car car)
|
||||
{
|
||||
if (id != car.Id)
|
||||
@@ -122,6 +124,7 @@ namespace WebApp.Controllers
|
||||
|
||||
// GET: Cars/Delete/5
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
|
||||
@@ -7,9 +7,21 @@ using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Data;
|
||||
using Data.Entities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace WebApp.Controllers
|
||||
{
|
||||
public class UserWithRoles
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string PersonalNumber { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public string Role { get; set; }
|
||||
}
|
||||
|
||||
public class UsersController : Controller
|
||||
{
|
||||
private readonly RentACarDbContext _context;
|
||||
@@ -20,52 +32,36 @@ namespace WebApp.Controllers
|
||||
}
|
||||
|
||||
// GET: Users
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Users.ToListAsync());
|
||||
}
|
||||
ICollection<User> users = await _context.Users.ToListAsync();
|
||||
|
||||
// GET: Users/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ICollection<UserWithRoles> usersWithRole = new List<UserWithRoles>();
|
||||
|
||||
var user = await _context.Users
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
//foreach (var item in users)
|
||||
//{
|
||||
// var userRole = await _context.UserRoles.FirstOrDefaultAsync(userRoles => userRoles.UserId == item.Id);
|
||||
// var role = await _context.Roles.FirstOrDefaultAsync(role => role.Id == userRole.RoleId);
|
||||
// usersWithRole.Add(
|
||||
// new UserWithRoles()
|
||||
// {
|
||||
// UserName = item.UserName,
|
||||
// FirstName = item.FirstName,
|
||||
// LastName = item.LastName,
|
||||
// Email = item.Email,
|
||||
// PersonalNumber = item.PersonalNumber,
|
||||
// PhoneNumber = item.PhoneNumber,
|
||||
// Role = role.Name
|
||||
// }
|
||||
// );
|
||||
//}
|
||||
|
||||
return View(user);
|
||||
}
|
||||
|
||||
// GET: Users/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Users/Create
|
||||
// To protect from overposting attacks, enable the specific properties you want to bind to.
|
||||
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create([Bind("FirstName,LastName,PersonalNumber,Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] User user)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Add(user);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
return View(user);
|
||||
return View(users);
|
||||
}
|
||||
|
||||
// GET: Users/Edit/5
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
@@ -86,6 +82,7 @@ namespace WebApp.Controllers
|
||||
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Edit(string id, [Bind("FirstName,LastName,PersonalNumber,Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] User user)
|
||||
{
|
||||
if (id != user.Id)
|
||||
@@ -117,6 +114,7 @@ namespace WebApp.Controllers
|
||||
}
|
||||
|
||||
// GET: Users/Delete/5
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
@@ -137,6 +135,7 @@ namespace WebApp.Controllers
|
||||
// POST: Users/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
var user = await _context.Users.FindAsync(id);
|
||||
|
||||
@@ -27,6 +27,12 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Rents" asp-action="Index">Rents</a>
|
||||
</li>
|
||||
@if (this.User.IsInRole("Admin"))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Users" asp-action="Index">Users</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<partial name="_LoginPartial" />
|
||||
</div>
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
@model Data.Entities.User
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h1>Create</h1>
|
||||
|
||||
<h4>User</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="FirstName" class="control-label"></label>
|
||||
<input asp-for="FirstName" class="form-control" />
|
||||
<span asp-validation-for="FirstName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="LastName" class="control-label"></label>
|
||||
<input asp-for="LastName" class="form-control" />
|
||||
<span asp-validation-for="LastName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="PersonalNumber" class="control-label"></label>
|
||||
<input asp-for="PersonalNumber" class="form-control" />
|
||||
<span asp-validation-for="PersonalNumber" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Id" class="control-label"></label>
|
||||
<input asp-for="Id" class="form-control" />
|
||||
<span asp-validation-for="Id" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="UserName" class="control-label"></label>
|
||||
<input asp-for="UserName" class="form-control" />
|
||||
<span asp-validation-for="UserName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="NormalizedUserName" class="control-label"></label>
|
||||
<input asp-for="NormalizedUserName" class="form-control" />
|
||||
<span asp-validation-for="NormalizedUserName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Email" class="control-label"></label>
|
||||
<input asp-for="Email" class="form-control" />
|
||||
<span asp-validation-for="Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="NormalizedEmail" class="control-label"></label>
|
||||
<input asp-for="NormalizedEmail" class="form-control" />
|
||||
<span asp-validation-for="NormalizedEmail" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="EmailConfirmed" /> @Html.DisplayNameFor(model => model.EmailConfirmed)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="PasswordHash" class="control-label"></label>
|
||||
<input asp-for="PasswordHash" class="form-control" />
|
||||
<span asp-validation-for="PasswordHash" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="SecurityStamp" class="control-label"></label>
|
||||
<input asp-for="SecurityStamp" class="form-control" />
|
||||
<span asp-validation-for="SecurityStamp" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ConcurrencyStamp" class="control-label"></label>
|
||||
<input asp-for="ConcurrencyStamp" class="form-control" />
|
||||
<span asp-validation-for="ConcurrencyStamp" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="PhoneNumber" class="control-label"></label>
|
||||
<input asp-for="PhoneNumber" class="form-control" />
|
||||
<span asp-validation-for="PhoneNumber" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="PhoneNumberConfirmed" /> @Html.DisplayNameFor(model => model.PhoneNumberConfirmed)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="TwoFactorEnabled" /> @Html.DisplayNameFor(model => model.TwoFactorEnabled)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="LockoutEnd" class="control-label"></label>
|
||||
<input asp-for="LockoutEnd" class="form-control" />
|
||||
<span asp-validation-for="LockoutEnd" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="LockoutEnabled" /> @Html.DisplayNameFor(model => model.LockoutEnabled)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="AccessFailedCount" class="control-label"></label>
|
||||
<input asp-for="AccessFailedCount" class="form-control" />
|
||||
<span asp-validation-for="AccessFailedCount" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -6,9 +6,6 @@
|
||||
|
||||
<h1>Index</h1>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -24,45 +21,12 @@
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.UserName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.NormalizedUserName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Email)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.NormalizedEmail)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.EmailConfirmed)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.PasswordHash)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SecurityStamp)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.ConcurrencyStamp)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.PhoneNumber)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.PhoneNumberConfirmed)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.TwoFactorEnabled)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.LockoutEnd)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.LockoutEnabled)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.AccessFailedCount)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -81,45 +45,12 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.UserName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.NormalizedUserName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Email)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.NormalizedEmail)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.EmailConfirmed)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PasswordHash)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.SecurityStamp)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ConcurrencyStamp)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PhoneNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PhoneNumberConfirmed)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.TwoFactorEnabled)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.LockoutEnd)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.LockoutEnabled)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.AccessFailedCount)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;"
|
||||
"DefaultConnection": "Server=.;Database=RentACar;Integrated Security=true;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;"
|
||||
"DefaultConnection": "Server=.;Database=RentACar;Integrated Security=true;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
Reference in New Issue
Block a user