Prvi commit
This commit is contained in:
185
EveryThing/Pages/CodeTableEmployees/Create.cshtml
Normal file
185
EveryThing/Pages/CodeTableEmployees/Create.cshtml
Normal file
@@ -0,0 +1,185 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableEmployees.CreateModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Vnos delavca";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
|
||||
}
|
||||
|
||||
<form enctype="multipart/form-data" 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">Zaposleni /</span> Nov
|
||||
</span>
|
||||
|
||||
<span class="text-right">
|
||||
<a asp-page="Index" class="btn btn-default"><span class="fa fas fa-times"></span> Prekliči</a>
|
||||
<button type="submit" class="btn btn-primary"><span class="fa fas fa-plus"></span> Dodaj delavca</button>
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Osnovni podatki
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center">
|
||||
<img id="btn-profile-image" src="~/img/img_avatar.png" style="cursor: pointer;" />
|
||||
<input id="profile-image" asp-for="Employee.ProfileImage" class="form-control" type="file" style="display: none" />
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.FirstName" class="form-label"></label>
|
||||
<input asp-for="Employee.FirstName" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.LastName" class="form-label"></label>
|
||||
<input asp-for="Employee.LastName" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.Gender" class="form-label"></label>
|
||||
<select asp-for="Employee.Gender" class="form-control selectpicker" data-style="btn-default" asp-items="Html.GetEnumSelectList<Models.CodeTable.CodeTableEmployeeGender>()">
|
||||
<option value="">Izberite spol</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.BirthDate" class="form-label"></label>
|
||||
<input asp-for="Employee.BirthDate" type="text" class="form-control dtp-datenotime" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.EmploymentDate" class="form-label"></label>
|
||||
<input asp-for="Employee.EmploymentDate" type="text" class="form-control dtp-datenotime" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.CitizenIdNumber" class="form-label"></label>
|
||||
<input asp-for="Employee.CitizenIdNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.TaxNumber" class="form-label"></label>
|
||||
<input asp-for="Employee.TaxNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<label asp-for="Employee.BankAccount" class="form-label"></label>
|
||||
<input asp-for="Employee.BankAccount" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<hr class="mb-0 mt-0" />
|
||||
<div class="card-body">
|
||||
<div class="text-light small font-weight-semibold mb-3">Kontaktni podatki</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.Telephone" class="form-label"></label>
|
||||
<input asp-for="Employee.Telephone" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.MobileTelephone" class="form-label"></label>
|
||||
<input asp-for="Employee.MobileTelephone" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.Email" class="form-label"></label>
|
||||
<input asp-for="Employee.Email" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki o prebivališču
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<div class="text-light small font-weight-semibold mb-3">Stalni naslov</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.Street" class="form-label"></label>
|
||||
<input asp-for="Employee.Street" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.HouseNumber" class="form-label"></label>
|
||||
<input asp-for="Employee.HouseNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-0">
|
||||
<label asp-for="Employee.City" class="form-label"></label>
|
||||
<input asp-for="Employee.City" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<hr class="mb-0 mt-0" />
|
||||
<div class="card-body">
|
||||
<div class="text-light small font-weight-semibold mb-3">Začasni naslov</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.TemporaryStreet" class="form-label"></label>
|
||||
<input asp-for="Employee.TemporaryStreet" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.TemporaryHouseNumber" class="form-label"></label>
|
||||
<input asp-for="Employee.TemporaryHouseNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.TemporaryCity" class="form-label"></label>
|
||||
<input asp-for="Employee.TemporaryCity" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<!-- Modal placeholder -->
|
||||
<div id="modal-placeholder"></div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
|
||||
<script>
|
||||
$('#btn-profile-image').on('click', function () {
|
||||
$('#profile-image').trigger('click');
|
||||
});
|
||||
</script>
|
||||
}
|
||||
86
EveryThing/Pages/CodeTableEmployees/Create.cshtml.cs
Normal file
86
EveryThing/Pages/CodeTableEmployees/Create.cshtml.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableEmployees
|
||||
{
|
||||
[Authorize]
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
[BindProperty]
|
||||
public CodeTableEmployee Employee { get; set; }
|
||||
|
||||
public CreateModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
//if (ModelState.IsValid)
|
||||
//{
|
||||
// _context.Add(employee);
|
||||
// await _context.SaveChangesAsync();
|
||||
|
||||
// //Izbrana profilna slika
|
||||
// if (employee.ProfileImage != null)
|
||||
// {
|
||||
// var file = employee.ProfileImage;
|
||||
// var parsedContentDisposition = ContentDispositionHeaderValue.Parse(file.ContentDisposition);
|
||||
|
||||
// //Pot datoteke
|
||||
// var fileName = employee.IdEmployee + Path.GetExtension(parsedContentDisposition.FileName.ToString());
|
||||
// var filePath = Path.Combine(_hostingEnvironment.WebRootPath, "uploads", "profile-images", fileName);
|
||||
|
||||
// //Nalaganje
|
||||
// using (var stream = System.IO.File.OpenWrite(filePath))
|
||||
// {
|
||||
// await file.CopyToAsync(stream);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return RedirectToAction(nameof(Index));
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
Employee.IdCompanyFk = user.IdCompanyFk;
|
||||
Employee.Active = true;
|
||||
|
||||
_context.CodeTableEmployees.Add(Employee);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
137
EveryThing/Pages/CodeTableEmployees/Delete.cshtml
Normal file
137
EveryThing/Pages/CodeTableEmployees/Delete.cshtml
Normal file
@@ -0,0 +1,137 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableEmployees.DeleteModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Employee</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.IdCompanyFk)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.IdCompanyFk)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.FirstName)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.FirstName)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.LastName)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.LastName)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.Gender)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.Gender)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.BirthDate)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.BirthDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.City)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.City)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.Street)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.Street)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.HouseNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.HouseNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.TemporaryCity)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.TemporaryCity)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.TemporaryStreet)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.TemporaryStreet)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.TemporaryHouseNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.TemporaryHouseNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.CitizenIdNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.CitizenIdNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.Telephone)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.Telephone)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.MobileTelephone)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.MobileTelephone)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.Email)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.Email)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.TaxNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.TaxNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.BankAccount)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.BankAccount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.EmploymentDate)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.EmploymentDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Employee.Active)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Employee.Active)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Employee.IdEmployee" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
62
EveryThing/Pages/CodeTableEmployees/Delete.cshtml.cs
Normal file
62
EveryThing/Pages/CodeTableEmployees/Delete.cshtml.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableEmployees
|
||||
{
|
||||
[Authorize]
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTableEmployee Employee { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Employee = await _context.CodeTableEmployees.FirstOrDefaultAsync(m => m.IdEmployee == id);
|
||||
|
||||
if (Employee == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Employee = await _context.CodeTableEmployees.FindAsync(id);
|
||||
|
||||
if (Employee != null)
|
||||
{
|
||||
_context.CodeTableEmployees.Remove(Employee);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
189
EveryThing/Pages/CodeTableEmployees/Edit.cshtml
Normal file
189
EveryThing/Pages/CodeTableEmployees/Edit.cshtml
Normal file
@@ -0,0 +1,189 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableEmployees.EditModel
|
||||
|
||||
@{
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
<link rel="stylesheet" href="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.css">
|
||||
}
|
||||
|
||||
<form enctype="multipart/form-data" 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">Zaposleni /</span> Urejanje
|
||||
</span>
|
||||
<button type="submit" class="btn btn-secondary"><span class="ion ion-md-save"></span> Shrani delavca</button>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Osnovni podatki
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center">
|
||||
<img id="btn-profile-image" src="~/img/img_avatar.png" style="cursor: pointer;" />
|
||||
<input id="profile-image" asp-for="Employee.ProfileImage" class="form-control" type="file" style="display: none" />
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.FirstName" class="form-label"></label>
|
||||
<input asp-for="Employee.FirstName" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.LastName" class="form-label"></label>
|
||||
<input asp-for="Employee.LastName" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.Gender" class="form-label"></label>
|
||||
<select asp-for="Employee.Gender" class="form-control selectpicker" data-style="btn-default" asp-items="Html.GetEnumSelectList<Models.CodeTable.CodeTableEmployeeGender>()">
|
||||
<option value="">Izberite spol</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.BirthDate" class="form-label"></label>
|
||||
<input asp-for="Employee.BirthDate" type="text" class="form-control dtp-datenotime" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.EmploymentDate" class="form-label"></label>
|
||||
<input asp-for="Employee.EmploymentDate" type="text" class="form-control dtp-datenotime" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.CitizenIdNumber" class="form-label"></label>
|
||||
<input asp-for="Employee.CitizenIdNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.TaxNumber" class="form-label"></label>
|
||||
<input asp-for="Employee.TaxNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<label asp-for="Employee.BankAccount" class="form-label"></label>
|
||||
<input asp-for="Employee.BankAccount" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<hr class="mb-0 mt-0" />
|
||||
<div class="card-body">
|
||||
<div class="text-light small font-weight-semibold mb-3">Kontaktni podatki</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.Telephone" class="form-label"></label>
|
||||
<input asp-for="Employee.Telephone" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.MobileTelephone" class="form-label"></label>
|
||||
<input asp-for="Employee.MobileTelephone" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.Email" class="form-label"></label>
|
||||
<input asp-for="Employee.Email" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki o prebivališču
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<div class="text-light small font-weight-semibold mb-3">Stalni naslov</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.Street" class="form-label"></label>
|
||||
<input asp-for="Employee.Street" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.HouseNumber" class="form-label"></label>
|
||||
<input asp-for="Employee.HouseNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-0">
|
||||
<label asp-for="Employee.City" class="form-label"></label>
|
||||
<input asp-for="Employee.City" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<hr class="mb-0 mt-0" />
|
||||
<div class="card-body">
|
||||
<div class="text-light small font-weight-semibold mb-3">Začasni naslov</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.TemporaryStreet" class="form-label"></label>
|
||||
<input asp-for="Employee.TemporaryStreet" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.TemporaryHouseNumber" class="form-label"></label>
|
||||
<input asp-for="Employee.TemporaryHouseNumber" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="Employee.TemporaryCity" class="form-label"></label>
|
||||
<input asp-for="Employee.TemporaryCity" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Dokumenti
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<partial name="Documents/IndexModal" model="Model.Document" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Modal placeholder -->
|
||||
<div id="modal-placeholder"></div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
|
||||
<script src="~/vendor/libs/moment/moment.js"></script>
|
||||
<script src="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.js"></script>
|
||||
|
||||
<script>
|
||||
$('#btn-profile-image').on('click', function () {
|
||||
$('#profile-image').trigger('click');
|
||||
});
|
||||
</script>
|
||||
}
|
||||
79
EveryThing/Pages/CodeTableEmployees/Edit.cshtml.cs
Normal file
79
EveryThing/Pages/CodeTableEmployees/Edit.cshtml.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableEmployees
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public EditModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTableEmployee Employee { get; set; }
|
||||
|
||||
public IList<Document> Document { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Employee = await _context.CodeTableEmployees.FirstOrDefaultAsync(m => m.IdEmployee == id);
|
||||
Document = await _context.Documents.Include(d => d.DocumentType).ToListAsync();
|
||||
|
||||
if (Employee == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(Employee).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!EmployeeExists(Employee.IdEmployee))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool EmployeeExists(int id)
|
||||
{
|
||||
return _context.CodeTableEmployees.Any(e => e.IdEmployee == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
103
EveryThing/Pages/CodeTableEmployees/Index.cshtml
Normal file
103
EveryThing/Pages/CodeTableEmployees/Index.cshtml
Normal file
@@ -0,0 +1,103 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableEmployees.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Zaposleni";
|
||||
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">Zaposleni /</span> Pregled
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mb-2 text-right">
|
||||
<form method="get">
|
||||
<div class="btn-group">
|
||||
<input class="form-control" type="text" name="searchString" value="@ViewData["SearchString"]" placeholder="Iskanje..." autocomplete="off">
|
||||
<button type="submit" class="btn btn-secondary" aria-label="Osveži" title="Osveži">
|
||||
<i class="opacity-75 ion ion-md-refresh"></i>
|
||||
</button>
|
||||
<div class="btn-group" title="Columns">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-label="Nastavitve" title="Nastavitve">
|
||||
<i class="opacity-75 ion ion-md-apps"></i>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="inactiveEmployees" @ViewData["InactiveEmployees"]> <span>Neaktivni zaposleni</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<h6 class="card-header">
|
||||
Seznam zaposlenih
|
||||
</h6>
|
||||
|
||||
<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Employee[0].FirstName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Employee[0].LastName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Employee[0].BirthDate)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Employee[0].Telephone)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Employee[0].MobileTelephone)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Employee[0].Email)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Employee)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.LastName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.LastName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.BirthDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Telephone)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.MobileTelephone)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Email)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.IdEmployee">Edit</a> | <a asp-page="./Details" asp-route-id="@item.IdEmployee">Details</a> | <a asp-page="./Delete" asp-route-id="@item.IdEmployee">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="card-footer py-3 text-right">
|
||||
<a asp-page="Create" class="btn btn-primary">Vnos delavca</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
45
EveryThing/Pages/CodeTableEmployees/Index.cshtml.cs
Normal file
45
EveryThing/Pages/CodeTableEmployees/Index.cshtml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableEmployees
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public IndexModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IList<CodeTableEmployee> Employee {get; set;}
|
||||
|
||||
public async Task OnGetAsync(string searchString, string inactiveEmployees)
|
||||
{
|
||||
ViewData["SearchString"] = searchString;
|
||||
ViewData["InactiveEmployees"] = inactiveEmployees == "on" ? "checked" : "";
|
||||
|
||||
Employee = await _context.CodeTableEmployees.ToListAsync();
|
||||
|
||||
// Active companies
|
||||
if (string.IsNullOrEmpty(inactiveEmployees) || inactiveEmployees != "on")
|
||||
{
|
||||
Employee = Employee.Where(s => s.Active).ToList();
|
||||
}
|
||||
|
||||
// Search string
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
Employee = Employee.Where(s => s.FirstName.Contains(searchString) || s.LastName.Contains(searchString)).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user