prvi
This commit is contained in:
93
EveryThing/Pages/AdministrationUsers/Create.cshtml
Normal file
93
EveryThing/Pages/AdministrationUsers/Create.cshtml
Normal file
@@ -0,0 +1,93 @@
|
||||
@page
|
||||
@model EveryThing.Pages.AdministrationUsers.CreateModel
|
||||
@{
|
||||
ViewData["Title"] = "Vnos uporabnika";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Uporabniki /</span> Nov
|
||||
</span>
|
||||
</h4>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki uporabnika
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="Input.IdCompanyFk" />
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.Name" class="form-label"></label>
|
||||
<input asp-for="Input.Name" class="form-control" />
|
||||
<span asp-validation-for="Input.Name" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.LastName" class="form-label"></label>
|
||||
<input asp-for="Input.LastName" class="form-control" />
|
||||
<span asp-validation-for="Input.LastName" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.UserName" class="form-label"></label>
|
||||
<input asp-for="Input.UserName" class="form-control" />
|
||||
<span asp-validation-for="Input.UserName" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.Password" class="form-label"></label>
|
||||
<input asp-for="Input.Password" type="password" class="form-control" />
|
||||
<span asp-validation-for="Input.Password" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.Email" class="form-label"></label>
|
||||
<input asp-for="Input.Email" class="form-control" />
|
||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.Phone" class="form-label"></label>
|
||||
<input asp-for="Input.Phone" class="form-control" />
|
||||
<span asp-validation-for="Input.Phone" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.DateValidUntil" class="form-label"></label>
|
||||
<input asp-for="Input.DateValidUntil" class="form-control" />
|
||||
<span asp-validation-for="Input.DateValidUntil" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Dodaj uporabnika</button>
|
||||
<a asp-page="/AdministrationCompanies/Edit" asp-route-id="@ViewBag.IdCompany" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
129
EveryThing/Pages/AdministrationUsers/Create.cshtml.cs
Normal file
129
EveryThing/Pages/AdministrationUsers/Create.cshtml.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace EveryThing.Pages.AdministrationUsers
|
||||
{
|
||||
[Authorize(Roles = "Administrator")]
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public CreateModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public InputModel Input { get; set; }
|
||||
|
||||
public IActionResult OnGet(int idCompany)
|
||||
{
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Title");
|
||||
ViewData["IdCompany"] = idCompany;
|
||||
|
||||
Input = new InputModel()
|
||||
{
|
||||
IdCompanyFk = idCompany
|
||||
};
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityApplicationUser identityApplicationUser = new IdentityApplicationUser
|
||||
{
|
||||
Name = Input.Name,
|
||||
Surname = Input.LastName,
|
||||
UserName = Input.UserName,
|
||||
NormalizedUserName = Input.UserName.ToLower(),
|
||||
Email = Input.Email,
|
||||
NormalizedEmail = Input.Email.ToLower(),
|
||||
EmailConfirmed = true,
|
||||
DateCreated = DateTime.Now,
|
||||
DateValidUntil = Input.DateValidUntil,
|
||||
PhoneNumber = Input.Phone,
|
||||
PhoneNumberConfirmed = true,
|
||||
Active = true,
|
||||
IdCompanyFk = Input.IdCompanyFk
|
||||
};
|
||||
|
||||
IdentityResult identityResult = await _userManager.CreateAsync(identityApplicationUser, Input.Password);
|
||||
|
||||
if (identityResult.Succeeded)
|
||||
{
|
||||
//await _userManager.AddToRoleAsync(identityApplicationUser, "NormalUser");
|
||||
return RedirectToPage("/AdministrationUsers/Edit", new { idCompany = identityApplicationUser.IdCompanyFk, idUser = identityApplicationUser.Id });
|
||||
//return RedirectToPage("/Administration/Users/Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelState.AddModelError("", string.Join(",", identityResult.Errors.Select(x => x.Description)));
|
||||
}
|
||||
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Title");
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public class InputModel
|
||||
{
|
||||
public int IdCompanyFk { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Ime")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Priimek")]
|
||||
public string LastName { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Uporabniško ime")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Geslo")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "E-pošta")]
|
||||
[DataType(DataType.EmailAddress)]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Display(Name = "Telefon")]
|
||||
public string Phone { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.Date)]
|
||||
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
|
||||
[Display(Name = "Veljavnost uporabnika do")]
|
||||
public DateTime DateValidUntil { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
124
EveryThing/Pages/AdministrationUsers/Edit.cshtml
Normal file
124
EveryThing/Pages/AdministrationUsers/Edit.cshtml
Normal file
@@ -0,0 +1,124 @@
|
||||
@page
|
||||
@model EveryThing.Pages.AdministrationUsers.EditModel
|
||||
@{
|
||||
ViewData["Title"] = "Urejanje uporabnika";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Uporabniki /</span> Urejanje
|
||||
</span>
|
||||
</h4>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki uporabnika
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
@*<input type="hidden" asp-for="Input.UserName" />*@
|
||||
<input type="hidden" asp-for="Input.IdUser" />
|
||||
<input type="hidden" asp-for="Input.Active" />
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.Name" class="form-label"></label>
|
||||
<input asp-for="Input.Name" class="form-control" />
|
||||
<span asp-validation-for="Input.Name" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.LastName" class="form-label"></label>
|
||||
<input asp-for="Input.LastName" class="form-control" />
|
||||
<span asp-validation-for="Input.LastName" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* <div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.UserName" class="form-label"></label>
|
||||
<input asp-for="Input.UserName" class="form-control" />
|
||||
<span asp-validation-for="Input.UserName" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.Password" class="form-label"></label>
|
||||
<input asp-for="Input.Password" type="password" class="form-control" />
|
||||
<span asp-validation-for="Input.Password" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.Email" class="form-label"></label>
|
||||
<input asp-for="Input.Email" class="form-control" />
|
||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.Phone" class="form-label"></label>
|
||||
<input asp-for="Input.Phone" class="form-control" />
|
||||
<span asp-validation-for="Input.Phone" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Input.DateValidUntil" class="form-label"></label>
|
||||
@Html.TextBoxFor(m => m.Input.DateValidUntil, "{0:yyyy-MM-dd}", new { @class = "form-control", type = "date" })
|
||||
<span asp-validation-for="Input.DateValidUntil" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<h5>Pravice</h5>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Roles[0].RoleDescription)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Roles[0].InRole)
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (int i = 0; i < Model.Roles.Count; i++)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(x => Model.Roles[i].RoleDescription)
|
||||
@Html.HiddenFor(x => Model.Roles[i].RoleName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.CheckBoxFor(x => Model.Roles[i].InRole)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Shrani</button>
|
||||
<a asp-page="/AdministrationCompanies/Edit" asp-route-id="@ViewBag.IdCompany" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
218
EveryThing/Pages/AdministrationUsers/Edit.cshtml.cs
Normal file
218
EveryThing/Pages/AdministrationUsers/Edit.cshtml.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EveryThing.Pages.AdministrationUsers
|
||||
{
|
||||
[Authorize(Roles = "Administrator")]
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public EditModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public InputModel Input { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public List<InputRole> Roles { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? idCompany, int? idUser)
|
||||
{
|
||||
if (idUser == null || idCompany == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var user = await _userManager.Users.FirstAsync(x => x.IdCompanyFk == idCompany && x.Id == idUser);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
var userRoles = await _userManager.GetRolesAsync(user);
|
||||
|
||||
ViewData["IdCompany"] = user.IdCompanyFk;
|
||||
|
||||
Input = new()
|
||||
{
|
||||
//UserName = user.UserName,
|
||||
Name = user.Name,
|
||||
LastName = user.Surname,
|
||||
Email = user.Email,
|
||||
Phone = user.PhoneNumber,
|
||||
DateValidUntil = user.DateValidUntil,
|
||||
Active = user.Active,
|
||||
IdUser = user.Id
|
||||
};
|
||||
|
||||
Roles = _roleManager.Roles.Select(x => new InputRole
|
||||
{
|
||||
RoleName = x.Name,
|
||||
RoleDescription = x.Description,
|
||||
InRole = userRoles.Contains(x.Name)
|
||||
}).ToList();
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
var user = await _userManager.FindByIdAsync(Input.IdUser.ToString());
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
ModelState.AddModelError("", "Napaka uporabnika");
|
||||
return Page();
|
||||
}
|
||||
|
||||
user.Name = Input.Name;
|
||||
user.Surname = Input.LastName;
|
||||
user.Email = Input.Email;
|
||||
user.NormalizedEmail = Input.Email.ToUpper();
|
||||
user.PhoneNumber = Input.Phone;
|
||||
user.DateValidUntil = Input.DateValidUntil;
|
||||
user.Active = Input.Active;
|
||||
|
||||
var result = await _userManager.UpdateAsync(user);
|
||||
var userRoles = await _userManager.GetRolesAsync(user);
|
||||
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
ModelState.AddModelError("", "Napaka uporabnika");
|
||||
return Page();
|
||||
}
|
||||
|
||||
foreach (var role in Roles)
|
||||
{
|
||||
if (role.InRole)
|
||||
{
|
||||
//Dodam ce se ni
|
||||
if (!userRoles.Contains(role.RoleName))
|
||||
await _userManager.AddToRoleAsync(user, role.RoleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ce je v roli ga odstranim
|
||||
if (userRoles.Contains(role.RoleName))
|
||||
await _userManager.RemoveFromRoleAsync(user, role.RoleName);
|
||||
}
|
||||
}
|
||||
|
||||
//if (!string.IsNullOrEmpty(Input.Password))
|
||||
//{
|
||||
// var token = await _userManager.GeneratePasswordResetTokenAsync(user);
|
||||
// result = await _userManager.ResetPasswordAsync(user, token, Input.Password);
|
||||
|
||||
// if (!result.Succeeded)
|
||||
// {
|
||||
// ModelState.AddModelError("", "Napaka shranjevanje novega gesla");
|
||||
// }
|
||||
//}
|
||||
|
||||
return RedirectToPage("/AdministrationCompanies/Edit", new { id = user.IdCompanyFk});
|
||||
|
||||
//if (identityResult.Succeeded)
|
||||
//{
|
||||
// if (!_roleManager.RoleExistsAsync("NormalUser").Result)
|
||||
// {
|
||||
// IdentityApplicationRole normalUserRole = new IdentityApplicationRole
|
||||
// {
|
||||
// Name = "NormalUser",
|
||||
// Description = "Splo<6C>ni uporabniki"
|
||||
// };
|
||||
|
||||
// await _roleManager.CreateAsync(normalUserRole);
|
||||
// }
|
||||
|
||||
// await _userManager.AddToRoleAsync(identityApplicationUser, "NormalUser");
|
||||
|
||||
// return RedirectToPage("/Administration/Users/Index");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// ModelState.AddModelError("", string.Join(",", identityResult.Errors.Select(x => x.Description)));
|
||||
//}
|
||||
|
||||
//ViewData["IdCompanyFk"] = new SelectList(_context.Companies, "IdCompany", "Title");
|
||||
|
||||
|
||||
//await _userService.UpdateDisplayName(User, Input.DisplayName);
|
||||
//return RedirectToPage("/User/Login");
|
||||
}
|
||||
|
||||
public class InputModel
|
||||
{
|
||||
[Required]
|
||||
public int IdUser { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Ime")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Priimek")]
|
||||
public string LastName { get; set; }
|
||||
|
||||
//[Required]
|
||||
//[Display(Name = "Uporabniško ime")]
|
||||
//public string UserName { get; set; }
|
||||
|
||||
//[Required]
|
||||
//[DataType(DataType.Password)]
|
||||
//[Display(Name = "Geslo")]
|
||||
//public string Password { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "E-pošta")]
|
||||
[DataType(DataType.EmailAddress)]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Display(Name = "Telefon")]
|
||||
public string Phone { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.Date)]
|
||||
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
|
||||
[Display(Name = "Veljavnost uporabnika do")]
|
||||
public DateTime DateValidUntil { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Aktiven")]
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
|
||||
public class InputRole
|
||||
{
|
||||
public string RoleName { get; set; }
|
||||
[Display(Name = "Pravica")]
|
||||
public string RoleDescription{ get; set; }
|
||||
[Display(Name = "Omogoči")]
|
||||
public bool InRole { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
76
EveryThing/Pages/AdministrationUsers/Index.cshtml
Normal file
76
EveryThing/Pages/AdministrationUsers/Index.cshtml
Normal file
@@ -0,0 +1,76 @@
|
||||
@page
|
||||
@model EveryThing.Pages.AdministrationUsers.IndexModel
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-0 mb-0">
|
||||
Pregled podjetij
|
||||
<a asp-page="Create" class="btn btn-sm btn-primary"><span class="ion ion-md-add"></span> Vnos novega podjetja</a>
|
||||
</h5>
|
||||
</div>
|
||||
test
|
||||
@*<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company[0].Title)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company[0].City)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company[0].Street)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company[0].Post)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company[0].TaxNumber)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company[0].Email)
|
||||
</th>
|
||||
<th style="width: 80px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Company)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.City)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Street) @Html.DisplayFor(modelItem => item.HouseNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PostNumber) @Html.DisplayFor(modelItem => item.Post)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.RegistrationNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Email)
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="./Details" asp-route-id="@item.IdCompany" data-toggle="tooltip" data-placement="top" title="Podrobnosti" data-state="primary"><i class="fas fa-info"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="./Edit" asp-route-id="@item.IdCompany" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>*@
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||
</script>
|
||||
}
|
||||
40
EveryThing/Pages/AdministrationUsers/Index.cshtml.cs
Normal file
40
EveryThing/Pages/AdministrationUsers/Index.cshtml.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EveryThing.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EveryThing.Pages.AdministrationUsers
|
||||
{
|
||||
[Authorize(Roles = "Administrator")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly Data.ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public IndexModel(Data.ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public new IList<IdentityApplicationUser> User { get; set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
User = await _userManager.Users.ToListAsync();
|
||||
}
|
||||
|
||||
public IActionResult OnGetFrame()
|
||||
{
|
||||
User = _userManager.Users.ToList();
|
||||
|
||||
return Partial("IndexFrame");
|
||||
}
|
||||
}
|
||||
}
|
||||
37
EveryThing/Pages/AdministrationUsers/IndexFrame.cshtml
Normal file
37
EveryThing/Pages/AdministrationUsers/IndexFrame.cshtml
Normal file
@@ -0,0 +1,37 @@
|
||||
@model IList<EveryThing.Models.IdentityApplicationUser>
|
||||
|
||||
<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Ime
|
||||
</th>
|
||||
<th>
|
||||
Priimek
|
||||
</th>
|
||||
<th style="width: 140px;">
|
||||
Uporabniško ime
|
||||
</th>
|
||||
<th style="width: 30px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Surname)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.UserName)
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="/AdministrationUsers/Edit" asp-route-idCompany="@ViewBag.IdCompany" asp-route-idUser="@item.Id" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
Reference in New Issue
Block a user