prvi
This commit is contained in:
125
EveryThing/Pages/AdministrationCompanies/Create.cshtml
Normal file
125
EveryThing/Pages/AdministrationCompanies/Create.cshtml
Normal file
@@ -0,0 +1,125 @@
|
||||
@page
|
||||
@model EveryThing.Pages.AdministrationCompanies.CreateModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Vnos podjetja";
|
||||
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">Podjetja /</span> Novo
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki podjetja
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Title" class="form-label"></label>
|
||||
<input asp-for="Company.Title" class="form-control" />
|
||||
<span asp-validation-for="Company.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.ShortTitle" class="form-label"></label>
|
||||
<input asp-for="Company.ShortTitle" class="form-control" />
|
||||
<span asp-validation-for="Company.ShortTitle" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.IdCountryFk" class="form-label"></label>
|
||||
<select asp-for="Company.IdCountryFk" class="form-control" asp-items="ViewBag.IdCountryFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.City" class="form-label"></label>
|
||||
<input asp-for="Company.City" class="form-control" />
|
||||
<span asp-validation-for="Company.City" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Street" class="form-label"></label>
|
||||
<input asp-for="Company.Street" class="form-control" />
|
||||
<span asp-validation-for="Company.Street" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.HouseNumber" class="form-label"></label>
|
||||
<input asp-for="Company.HouseNumber" class="form-control" />
|
||||
<span asp-validation-for="Company.HouseNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Post" class="form-label"></label>
|
||||
<input asp-for="Company.Post" class="form-control" />
|
||||
<span asp-validation-for="Company.Post" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.TaxNumber" class="form-label"></label>
|
||||
<input asp-for="Company.TaxNumber" class="form-control" />
|
||||
<span asp-validation-for="Company.TaxNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.RegistrationNumber" class="form-label"></label>
|
||||
<input asp-for="Company.RegistrationNumber" class="form-control" />
|
||||
<span asp-validation-for="Company.RegistrationNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Email" class="form-label"></label>
|
||||
<input asp-for="Company.Email" class="form-control" />
|
||||
<span asp-validation-for="Company.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Bank" class="form-label"></label>
|
||||
<input asp-for="Company.Bank" class="form-control" />
|
||||
<span asp-validation-for="Company.Bank" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Iban" class="form-label"></label>
|
||||
<input asp-for="Company.Iban" class="form-control" />
|
||||
<span asp-validation-for="Company.Iban" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.SwiftBic" class="form-label"></label>
|
||||
<input asp-for="Company.SwiftBic" class="form-control" />
|
||||
<span asp-validation-for="Company.SwiftBic" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<label asp-for="Company.Ceo" class="form-label"></label>
|
||||
<input asp-for="Company.Ceo" class="form-control" />
|
||||
<span asp-validation-for="Company.Ceo" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.LogoFileName" class="form-label"></label>
|
||||
<input asp-for="Company.LogoFileName" class="form-control" />
|
||||
<span asp-validation-for="Company.LogoFileName" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Dodaj podjetje</button>
|
||||
<a asp-page="Index" 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");}
|
||||
}
|
||||
51
EveryThing/Pages/AdministrationCompanies/Create.cshtml.cs
Normal file
51
EveryThing/Pages/AdministrationCompanies/Create.cshtml.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
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.Authorization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Pages.AdministrationCompanies
|
||||
{
|
||||
[Authorize(Roles = "Administrator")]
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public CreateModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTableCompany Company { get; set; }
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
ViewData["IdCountryFk"] = new SelectList(_context.CodeTableCountries, "IdCountry", "Title");
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
ViewData["IdCountryFk"] = new SelectList(_context.CodeTableCountries, "IdCountry", "Title");
|
||||
|
||||
return Page();
|
||||
}
|
||||
Company.Active = true;
|
||||
_context.CodeTableCompanies.Add(Company);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
168
EveryThing/Pages/AdministrationCompanies/Edit.cshtml
Normal file
168
EveryThing/Pages/AdministrationCompanies/Edit.cshtml
Normal file
@@ -0,0 +1,168 @@
|
||||
@page
|
||||
@model EveryThing.Pages.AdministrationCompanies.EditModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Urejanje podjetja";
|
||||
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">Podjetja /</span> Urejanje
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki podjetja
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="Company.IdCompany" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Title" class="form-label"></label>
|
||||
<input asp-for="Company.Title" class="form-control" />
|
||||
<span asp-validation-for="Company.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.ShortTitle" class="form-label"></label>
|
||||
<input asp-for="Company.ShortTitle" class="form-control" />
|
||||
<span asp-validation-for="Company.ShortTitle" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.IdCountryFk" class="form-label"></label>
|
||||
<select asp-for="Company.IdCountryFk" class="form-control" asp-items="ViewBag.IdCountryFk"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.City" class="form-label"></label>
|
||||
<input asp-for="Company.City" class="form-control" />
|
||||
<span asp-validation-for="Company.City" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Street" class="form-label"></label>
|
||||
<input asp-for="Company.Street" class="form-control" />
|
||||
<span asp-validation-for="Company.Street" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.HouseNumber" class="form-label"></label>
|
||||
<input asp-for="Company.HouseNumber" class="form-control" />
|
||||
<span asp-validation-for="Company.HouseNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.PostNumber" class="form-label"></label>
|
||||
<input asp-for="Company.PostNumber" class="form-control" />
|
||||
<span asp-validation-for="Company.PostNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Post" class="form-label"></label>
|
||||
<input asp-for="Company.Post" class="form-control" />
|
||||
<span asp-validation-for="Company.Post" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.TaxNumber" class="form-label"></label>
|
||||
<input asp-for="Company.TaxNumber" class="form-control" />
|
||||
<span asp-validation-for="Company.TaxNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.RegistrationNumber" class="form-label"></label>
|
||||
<input asp-for="Company.RegistrationNumber" class="form-control" />
|
||||
<span asp-validation-for="Company.RegistrationNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Email" class="form-label"></label>
|
||||
<input asp-for="Company.Email" class="form-control" />
|
||||
<span asp-validation-for="Company.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Ceo" class="form-label"></label>
|
||||
<input asp-for="Company.Ceo" class="form-control" />
|
||||
<span asp-validation-for="Company.Ceo" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.SwiftBic" class="form-label"></label>
|
||||
<input asp-for="Company.SwiftBic" class="form-control" />
|
||||
<span asp-validation-for="Company.SwiftBic" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Iban" class="form-label"></label>
|
||||
<input asp-for="Company.Iban" class="form-control" />
|
||||
<span asp-validation-for="Company.Iban" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Bank" class="form-label"></label>
|
||||
<input asp-for="Company.Bank" class="form-control" />
|
||||
<span asp-validation-for="Company.Bank" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.Phone" class="form-label"></label>
|
||||
<input asp-for="Company.Phone" class="form-control" />
|
||||
<span asp-validation-for="Company.Phone" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Company.LogoFileName" class="form-label"></label>
|
||||
<input asp-for="Company.LogoFileName" class="form-control" />
|
||||
<span asp-validation-for="Company.LogoFileName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Company.Active" /> @Html.DisplayNameFor(model => model.Company.Active)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Shrani</button>
|
||||
<a asp-page="Index" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Uporabniki podjetja
|
||||
</h6>
|
||||
<partial name="AdministrationUsers/IndexFrame" model="Model.User" />
|
||||
<div class="card-footer py-3 text-right">
|
||||
<a asp-page="/AdministrationUsers/Create" asp-route-idCompany="@Model.Company.IdCompany" class="btn btn-primary">Vnos uporabnika</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||
</script>
|
||||
}
|
||||
87
EveryThing/Pages/AdministrationCompanies/Edit.cshtml.cs
Normal file
87
EveryThing/Pages/AdministrationCompanies/Edit.cshtml.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
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 Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Pages.AdministrationCompanies
|
||||
{
|
||||
[Authorize(Roles = "Administrator")]
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public EditModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTableCompany Company { get; set; }
|
||||
public new IList<IdentityApplicationUser> User { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Company = await _context.CodeTableCompanies.Include(c => c.Country).FirstOrDefaultAsync(m => m.IdCompany == id);
|
||||
User = await _userManager.Users.Include(x => x.Company).Where(x => x.IdCompanyFk == id).ToListAsync();
|
||||
ViewData["IdCompany"] = id;
|
||||
|
||||
if (Company == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewData["IdCountryFk"] = new SelectList(_context.CodeTableCountries, "IdCountry", "TranslationSlovenian");
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(Company).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!CompanyExists(Company.IdCompany))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool CompanyExists(int id)
|
||||
{
|
||||
return _context.CodeTableCompanies.Any(e => e.IdCompany == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
108
EveryThing/Pages/AdministrationCompanies/Index.cshtml
Normal file
108
EveryThing/Pages/AdministrationCompanies/Index.cshtml
Normal file
@@ -0,0 +1,108 @@
|
||||
@page
|
||||
@model EveryThing.Pages.AdministrationCompanies.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Podjetja";
|
||||
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">Podjetja /</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="inactiveCompanies" @ViewData["InactiveCompanies"]> <span>Neaktivna podjetja</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Seznam podjetij
|
||||
</h6>
|
||||
|
||||
<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 style="width: 140px;">
|
||||
@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)
|
||||
@if (!item.Active) {<span class='badge badge-danger'>Neaktivno</span>}
|
||||
</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 class="text-right">
|
||||
<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 class="card-footer py-3 text-right">
|
||||
<a asp-page="Create" class="btn btn-primary">Vnos podjetja</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||
</script>
|
||||
}
|
||||
48
EveryThing/Pages/AdministrationCompanies/Index.cshtml.cs
Normal file
48
EveryThing/Pages/AdministrationCompanies/Index.cshtml.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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 Microsoft.AspNetCore.Authorization;
|
||||
using EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Pages.AdministrationCompanies
|
||||
{
|
||||
[Authorize(Roles = "Administrator")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public IndexModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IList<CodeTableCompany> Company { get;set; }
|
||||
|
||||
public async Task OnGetAsync(string searchString, string inactiveCompanies)
|
||||
{
|
||||
ViewData["SearchString"] = searchString;
|
||||
ViewData["InactiveCompanies"] = inactiveCompanies == "on" ? "checked" : "";
|
||||
|
||||
Company = await _context.CodeTableCompanies
|
||||
.Include(c => c.Country).ToListAsync();
|
||||
|
||||
// Active companies
|
||||
if (string.IsNullOrEmpty(inactiveCompanies) || inactiveCompanies != "on")
|
||||
{
|
||||
Company = Company.Where(s => s.Active).ToList();
|
||||
}
|
||||
|
||||
// Search string
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
Company = Company.Where(s => s.ShortTitle.Contains(searchString) || s.Title.Contains(searchString)).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
EveryThing/Pages/AdministrationCompanies/Setup.cshtml
Normal file
6
EveryThing/Pages/AdministrationCompanies/Setup.cshtml
Normal file
@@ -0,0 +1,6 @@
|
||||
@page
|
||||
@model EveryThing.Pages.AdministrationCompanies.SetupModel
|
||||
@{
|
||||
ViewData["Title"] = "Odjava";
|
||||
Layout = "~/Pages/Layouts/_LayoutBlank.cshtml";
|
||||
}
|
||||
107
EveryThing/Pages/AdministrationCompanies/Setup.cshtml.cs
Normal file
107
EveryThing/Pages/AdministrationCompanies/Setup.cshtml.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
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.Extensions.Logging;
|
||||
|
||||
namespace EveryThing.Pages.AdministrationCompanies
|
||||
{
|
||||
[Authorize(Roles = "Administrator")]
|
||||
public class SetupModel : PageModel
|
||||
{
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _signInManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
private readonly ILogger<SetupModel> _logger;
|
||||
|
||||
public SetupModel(UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> signInManager, ILogger<SetupModel> logger, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_signInManager = signInManager;
|
||||
_logger = logger;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
//TODO osnovno podjetje?
|
||||
var rolesDefinitions = new List<(string RoleName, string RoleDescription)>
|
||||
{
|
||||
("TransportThingUser", "TransporThing uporabniki"),
|
||||
("ProjecThingUser", "ProjecThing uporabniki"),
|
||||
("InvoicingUser", "Fakturiranje uporabniki"),
|
||||
("Administrator", "Administratorji"),
|
||||
};
|
||||
|
||||
foreach (var roleDefinition in rolesDefinitions)
|
||||
{
|
||||
if (!_roleManager.RoleExistsAsync(roleDefinition.RoleName).Result)
|
||||
{
|
||||
var role = new IdentityApplicationRole
|
||||
{
|
||||
Name = roleDefinition.RoleName,
|
||||
Description = roleDefinition.RoleDescription
|
||||
};
|
||||
|
||||
_roleManager.CreateAsync(role).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
if (_userManager.FindByNameAsync("admin") == null)
|
||||
{
|
||||
IdentityApplicationUser identityApplicationUser = new IdentityApplicationUser
|
||||
{
|
||||
Name = "Master",
|
||||
Surname = "Admin",
|
||||
UserName = "admin",
|
||||
NormalizedUserName = "admin",
|
||||
Email = "admin@domain.com",
|
||||
NormalizedEmail = "admin@domain.com",
|
||||
EmailConfirmed = true,
|
||||
DateCreated = DateTime.Now,
|
||||
DateValidUntil = DateTime.MaxValue,
|
||||
PhoneNumber = "123456789",
|
||||
PhoneNumberConfirmed = true,
|
||||
Active = true,
|
||||
IdCompanyFk = 1
|
||||
};
|
||||
|
||||
var result = await _userManager.CreateAsync(identityApplicationUser, "Master#Admin22!");
|
||||
|
||||
if (result.Succeeded)
|
||||
{
|
||||
_userManager.AddToRoleAsync(identityApplicationUser, "Administrator").Wait();
|
||||
//return RedirectToPage("/Administration/Users/Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModelState.AddModelError("", string.Join(",", identityResult.Errors.Select(x => x.Description)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return RedirectToPage("/User/Login");
|
||||
}
|
||||
|
||||
//public async Task<IActionResult> OnPostAsync(string returnUrl = null)
|
||||
//{
|
||||
// var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
// await _signInManager.SignOutAsync();
|
||||
|
||||
// _logger.LogInformation($"Logout: {user.Name} {user.Surname} - {user.Company.Title}");
|
||||
|
||||
// if (returnUrl != null)
|
||||
// {
|
||||
// return LocalRedirect(returnUrl);
|
||||
// }
|
||||
|
||||
// return RedirectToPage();
|
||||
//}
|
||||
}
|
||||
}
|
||||
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>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
63
EveryThing/Pages/CodeTableItems/AddEditItemModal.cshtml
Normal file
63
EveryThing/Pages/CodeTableItems/AddEditItemModal.cshtml
Normal file
@@ -0,0 +1,63 @@
|
||||
@model EveryThing.Pages.CodeTableItems.IndexModel.AddEditCodeTableItem
|
||||
|
||||
<div class="modal" tabindex="-1" role="dialog" id="divModalAddEditCodeTableItem">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="modalAddEditCodeTableItemTitle">Dodajanje novega artikla</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input id="inpModalAddEditCodeTableItemIdCodeTableItem" type="hidden" asp-for="@Model.IdCodeTableItem" />
|
||||
<input id="inpModalAddEditCodeTableItemEdit" type="hidden" asp-for="@Model.Edit" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Item.Title" class="control-label"></label>
|
||||
<input id="inpModalAddEditCodeTableItemTitle" asp-for="Item.Title" class="form-control" />
|
||||
<span asp-validation-for="Item.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Item.Description" class="control-label"></label>
|
||||
<input id="inpModalAddEditCodeTableItemDescription" asp-for="Item.Description" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Item.CodeTableItemType" class="control-label"></label>
|
||||
<select id="selModalAddEditCodeTableItemType" asp-for="Item.CodeTableItemType" asp-items="Html.GetEnumSelectList<EveryThing.Models.CodeTable.CodeTableItemType>()" class="form-control" style="width: 100%">
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input id="inpModalAddEditCodeTableItemActive" class="form-check-input" asp-for="Item.Active" /> @Html.DisplayNameFor(model => model.Item.Active)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
Cena delo: <b>@Model.WorkPrice €</b>
|
||||
<br />Cena material: <b>@Model.WorkPrice €</b>
|
||||
<br />Cena skupaj: <b>@Model.TotalPrice €</b>
|
||||
<br />Prodajna cena: <b>@Model.SellingPrice €</b>
|
||||
<br />Razlika: <b>@Model.DifferenceInPricePercentage %</b>
|
||||
</div>
|
||||
@if (Model.Files != null && Model.Files.Count > 0)
|
||||
{
|
||||
<div class="form-group">
|
||||
@foreach (var file in Model.Files)
|
||||
{
|
||||
<div data-idfile="@file.IdFile">
|
||||
<a download href="@Url.Page("/Files/Upload", "DownloadFile", new { idFile = file.IdFile, idReferenceFk = file.IdReferenceFk, fileTypeInt = (int)file.FileType})" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Prenos" data-state="secondary"><i class="fas fa-download"></i></a>
|
||||
@Html.DisplayFor(modelItem => file.Title)
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="codeTableItemDeleteFile(this)"><i class="fas fa-times"></i></a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a id="btnModalAddEditCodeTableItemAddFile" asp-page="/Files/Upload" asp-route-idReferenceFk="@Model.IdCodeTableItem" asp-route-fileType="@Models.FileType.CodeTableItem" class="btn btn-primary pull-right">Priloži datoteko</a>
|
||||
<button id="btnModalAddEditCodeTableItemConfirm" type="button" class="btn btn-primary">Shrani</button>
|
||||
<button id="btnModalAddEditCodeTableItemCancel" type="button" class="btn btn-secondary">Prekliči</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
126
EveryThing/Pages/CodeTableItems/Index.cshtml
Normal file
126
EveryThing/Pages/CodeTableItems/Index.cshtml
Normal file
@@ -0,0 +1,126 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableItems.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
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">Artikli /</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 id="btnSubmit" 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="finishedProjects" @ViewData["FinishedProjects"]> <span>Aktivni artikli</span>
|
||||
</label>
|
||||
</div>*@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<h6 class="card-header">
|
||||
Seznam artiklov
|
||||
</h6>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Item[0].Title)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Item[0].Description)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Item[0].CodeTableItemType)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Item[0].Active)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Item)
|
||||
{
|
||||
<tr data-idCodeTableItem="@item.IdItem">
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Description)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CodeTableItemType)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Active)
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="editCodeTableItem(this);" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteCodeTableItem(this)"><i class="fas fa-times"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="button" class="btn btn-primary" onclick="addNewCodeTableItem();" >Vnos artikla</button>
|
||||
</div>
|
||||
<div id="divModalCodetableItemAddEditPlaceholder"></div>
|
||||
</div>
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts {
|
||||
|
||||
<script src="~/js/codeTableItemHelper.js?v=3" asp-append-version="true"></script>
|
||||
<script src="~/js/fileHelper.js?v=1" asp-append-version="true"></script>
|
||||
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||
|
||||
function addNewCodeTableItem() {
|
||||
codeTableItemAddEdit('#divModalCodetableItemAddEditPlaceholder', false, null, (idCodeTableItem) => {
|
||||
document.getElementById('btnSubmit').click();
|
||||
});
|
||||
}
|
||||
|
||||
function editCodeTableItem(element) {
|
||||
let idCodeTableItem = parseInt($(element).parent().parent().attr('data-idCodeTableItem'));
|
||||
|
||||
codeTableItemAddEdit('#divModalCodetableItemAddEditPlaceholder', true, idCodeTableItem, (idCodeTableItem) => {
|
||||
document.getElementById('btnSubmit').click();
|
||||
});
|
||||
}
|
||||
|
||||
function deleteCodeTableItem(element) {
|
||||
let row = $(element).parent().parent();
|
||||
let idCodeTableItem = parseInt(row.attr('data-idCodeTableItem'));
|
||||
|
||||
codeTableItemDelete(idCodeTableItem, (idCodeTableItem) => {
|
||||
row.remove();
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
||||
228
EveryThing/Pages/CodeTableItems/Index.cshtml.cs
Normal file
228
EveryThing/Pages/CodeTableItems/Index.cshtml.cs
Normal file
@@ -0,0 +1,228 @@
|
||||
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;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.VisualStudio.Debugger.Contracts;
|
||||
using System.Globalization;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableItems
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
public class AddEditCodeTableItem
|
||||
{
|
||||
public CodeTableItem Item { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
public int IdCodeTableItem { get; set; }
|
||||
public IList<File> Files { get; set; }
|
||||
public string MaterialPrice { get; set; }
|
||||
public string WorkPrice { get; set; }
|
||||
public string TotalPrice { get; set; }
|
||||
public string SellingPrice { get; set; }
|
||||
public string DifferenceInPricePercentage { get; set; }
|
||||
|
||||
}
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public IndexModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
public IList<CodeTableItem> Item { get;set; }
|
||||
|
||||
public async Task OnGetAsync(string searchString)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ViewData["SearchString"] = searchString;
|
||||
|
||||
Item = await _context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.Include(j => j.Company).ToListAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
Item = Item.Where(s => s.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase)
|
||||
|| (s.Description != null && s.Description.Contains(searchString, StringComparison.InvariantCultureIgnoreCase))).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IActionResult OnGetCodeTableItemModal(bool edit, int idCodeTableItem, int codeTableItemType)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
CodeTableItem item = null;
|
||||
IList<File> files = null;
|
||||
var materialPrice = 0d;
|
||||
var workPrice = 0d;
|
||||
var sellingPrice = 0d;
|
||||
var differenceInPricePercentage = 0d;
|
||||
|
||||
if (edit)
|
||||
{
|
||||
item = _context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdItem == idCodeTableItem);
|
||||
|
||||
files = _context.Files
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk
|
||||
&& x.IdReferenceFk == item.IdItem
|
||||
&& x.FileType == FileType.CodeTableItem)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
item = new CodeTableItem();
|
||||
item.Active = true;
|
||||
item.CodeTableItemType = (CodeTableItemType)codeTableItemType;
|
||||
}
|
||||
else
|
||||
{
|
||||
var projectPartItem = _context.ProjectPartItems
|
||||
.OrderByDescending(x => x.DateModified)
|
||||
.ThenByDescending(x => x.IdProjectPartItem)
|
||||
.FirstOrDefault(x => x.IdItemFk == item.IdItem);
|
||||
|
||||
if (projectPartItem != null)
|
||||
{
|
||||
materialPrice = projectPartItem.MaterialPrice;
|
||||
workPrice = projectPartItem.WorkPrice;
|
||||
sellingPrice = projectPartItem.SellingPrice;
|
||||
differenceInPricePercentage = projectPartItem.DifferenceInPricePercentage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Partial("AddEditItemModal", new AddEditCodeTableItem
|
||||
{
|
||||
Item = item,
|
||||
Edit = edit,
|
||||
IdCodeTableItem = idCodeTableItem,
|
||||
Files = files,
|
||||
MaterialPrice = materialPrice.ToString("#,###,##0.00", new CultureInfo("sl-SI")),
|
||||
SellingPrice = sellingPrice.ToString("#,###,##0.00", new CultureInfo("sl-SI")),
|
||||
TotalPrice = (materialPrice + workPrice).ToString("#,###,##0.00", new CultureInfo("sl-SI")),
|
||||
WorkPrice = workPrice.ToString("#,###,##0.00", new CultureInfo("sl-SI")),
|
||||
DifferenceInPricePercentage = differenceInPricePercentage.ToString("#,###,##0.00", new CultureInfo("sl-SI"))
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetCodeTableItem(int idCodeTableItem)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
bool successful = true;
|
||||
string error = "";
|
||||
bool itemInUse = false;
|
||||
|
||||
CodeTableItem item = _context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.Include(x => x.ItemProjectPartItem)
|
||||
.Include(x => x.ItemProjectPartItemMaterial)
|
||||
.Include(x => x.InvoiceItem)
|
||||
.FirstOrDefault(x => x.IdItem == idCodeTableItem);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
successful = false;
|
||||
error = $"Codetable item with ID: {idCodeTableItem} not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
itemInUse = item.ItemProjectPartItem.Count > 0 || item.ItemProjectPartItemMaterial.Count > 0 || item.InvoiceItem.Count > 0;
|
||||
//Cene se json zacikla neki IDK.
|
||||
item.ItemProjectPartItem = null;
|
||||
item.ItemProjectPartItemMaterial = null;
|
||||
item.InvoiceItem = null;
|
||||
}
|
||||
|
||||
return new JsonResult(new { item = item, error = error, successful = successful, itemInUse = itemInUse });
|
||||
}
|
||||
|
||||
public IActionResult OnPostCodeTableItem(string title, string description, bool active, bool edit, int idCodeTableItem, int codeTableItemType)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
bool successful = true;
|
||||
string error = "";
|
||||
if (edit)
|
||||
{
|
||||
var item = _context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdItem == idCodeTableItem);
|
||||
if (item != null)
|
||||
{
|
||||
item.Title = title;
|
||||
item.Description = description;
|
||||
item.Active = active;
|
||||
item.CodeTableItemType = (CodeTableItemType)codeTableItemType;
|
||||
_context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Codetable item with ID: {idCodeTableItem} not found";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = new CodeTableItem
|
||||
{
|
||||
Title = title,
|
||||
Description = description,
|
||||
Active = active,
|
||||
IdCompanyFk = user.IdCompanyFk,
|
||||
CodeTableItemType = (CodeTableItemType)codeTableItemType
|
||||
};
|
||||
_context.CodeTableItems.Add(item);
|
||||
_context.SaveChanges();
|
||||
|
||||
idCodeTableItem = item.IdItem;
|
||||
}
|
||||
|
||||
return new JsonResult(new { idCodeTableItem = idCodeTableItem, error = error, successful = successful });
|
||||
}
|
||||
|
||||
public IActionResult OnDeleteCodeTableItem(int idCodeTableItem)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
bool successful = true;
|
||||
string error = "";
|
||||
|
||||
var item = _context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdItem == idCodeTableItem);
|
||||
if (item != null)
|
||||
{
|
||||
_context.CodeTableItems.Remove(item);
|
||||
_context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Codetable item with ID: {idCodeTableItem} not found";
|
||||
}
|
||||
|
||||
return new JsonResult(new { idCodeTableItem = idCodeTableItem, error = error, successful = successful });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
44
EveryThing/Pages/CodeTableJobs/Create.cshtml
Normal file
44
EveryThing/Pages/CodeTableJobs/Create.cshtml
Normal file
@@ -0,0 +1,44 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableJobs.CreateModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Create</h1>
|
||||
|
||||
<h4>Job</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Job.IdCompanyFk" class="control-label"></label>
|
||||
<select asp-for="Job.IdCompanyFk" class ="form-control" asp-items="ViewBag.IdCompanyFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Job.Title" class="control-label"></label>
|
||||
<input asp-for="Job.Title" class="form-control" />
|
||||
<span asp-validation-for="Job.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Job.Active" /> @Html.DisplayNameFor(model => model.Job.Active)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
46
EveryThing/Pages/CodeTableJobs/Create.cshtml.cs
Normal file
46
EveryThing/Pages/CodeTableJobs/Create.cshtml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
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 EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableJobs
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public CreateModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Title");
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTableJob Job { get; set; }
|
||||
|
||||
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.CodeTableJobs.Add(Job);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
41
EveryThing/Pages/CodeTableJobs/Delete.cshtml
Normal file
41
EveryThing/Pages/CodeTableJobs/Delete.cshtml
Normal file
@@ -0,0 +1,41 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableJobs.DeleteModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Job</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Job.Title)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Job.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Job.Active)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Job.Active)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Job.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Job.Company.Ceo)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Job.IdJob" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
61
EveryThing/Pages/CodeTableJobs/Delete.cshtml.cs
Normal file
61
EveryThing/Pages/CodeTableJobs/Delete.cshtml.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
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.CodeTableJobs
|
||||
{
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTableJob Job { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Job = await _context.CodeTableJobs
|
||||
.Include(j => j.Company).FirstOrDefaultAsync(m => m.IdJob == id);
|
||||
|
||||
if (Job == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Job = await _context.CodeTableJobs.FindAsync(id);
|
||||
|
||||
if (Job != null)
|
||||
{
|
||||
_context.CodeTableJobs.Remove(Job);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
38
EveryThing/Pages/CodeTableJobs/Details.cshtml
Normal file
38
EveryThing/Pages/CodeTableJobs/Details.cshtml
Normal file
@@ -0,0 +1,38 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableJobs.DetailsModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>Job</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Job.Title)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Job.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Job.Active)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Job.Active)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Job.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Job.Company.Ceo)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Job.IdJob">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
42
EveryThing/Pages/CodeTableJobs/Details.cshtml.cs
Normal file
42
EveryThing/Pages/CodeTableJobs/Details.cshtml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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.CodeTableJobs
|
||||
{
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DetailsModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public CodeTableJob Job { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Job = await _context.CodeTableJobs
|
||||
.Include(j => j.Company).FirstOrDefaultAsync(m => m.IdJob == id);
|
||||
|
||||
if (Job == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
46
EveryThing/Pages/CodeTableJobs/Edit.cshtml
Normal file
46
EveryThing/Pages/CodeTableJobs/Edit.cshtml
Normal file
@@ -0,0 +1,46 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableJobs.EditModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Edit</h1>
|
||||
|
||||
<h4>Job</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Job.IdJob" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Job.IdCompanyFk" class="control-label"></label>
|
||||
<select asp-for="Job.IdCompanyFk" class="form-control" asp-items="ViewBag.IdCompanyFk"></select>
|
||||
<span asp-validation-for="Job.IdCompanyFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Job.Title" class="control-label"></label>
|
||||
<input asp-for="Job.Title" class="form-control" />
|
||||
<span asp-validation-for="Job.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Job.Active" /> @Html.DisplayNameFor(model => model.Job.Active)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
80
EveryThing/Pages/CodeTableJobs/Edit.cshtml.cs
Normal file
80
EveryThing/Pages/CodeTableJobs/Edit.cshtml.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
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.CodeTableJobs
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public EditModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTableJob Job { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Job = await _context.CodeTableJobs
|
||||
.Include(j => j.Company).FirstOrDefaultAsync(m => m.IdJob == id);
|
||||
|
||||
if (Job == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Ceo");
|
||||
return Page();
|
||||
}
|
||||
|
||||
// To protect from overposting attacks, enable the specific properties you want to bind to.
|
||||
// For more details, see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(Job).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!JobExists(Job.IdJob))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool JobExists(int id)
|
||||
{
|
||||
return _context.CodeTableJobs.Any(e => e.IdJob == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
EveryThing/Pages/CodeTableJobs/Index.cshtml
Normal file
49
EveryThing/Pages/CodeTableJobs/Index.cshtml
Normal file
@@ -0,0 +1,49 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableJobs.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Index</h1>
|
||||
|
||||
<p>
|
||||
<a asp-page="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Job[0].Title)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Job[0].Active)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Job[0].Company)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Job) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Active)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Company.Ceo)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.IdJob">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.IdJob">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.IdJob">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
31
EveryThing/Pages/CodeTableJobs/Index.cshtml.cs
Normal file
31
EveryThing/Pages/CodeTableJobs/Index.cshtml.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
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.CodeTableJobs
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public IndexModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IList<CodeTableJob> Job { get;set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
Job = await _context.CodeTableJobs
|
||||
.Include(j => j.Company).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
125
EveryThing/Pages/CodeTablePartners/Create.cshtml
Normal file
125
EveryThing/Pages/CodeTablePartners/Create.cshtml
Normal file
@@ -0,0 +1,125 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTablePartners.CreateModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Vnos partnerja";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<link rel="stylesheet" href="~/vendor/libs/select2/select2.css" asp-append-version="true" />
|
||||
|
||||
<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">Partner /</span> Nov
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki partnerja
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.Title" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Partner.Title" class="form-control" />
|
||||
<span asp-validation-for="Partner.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.IdCountryFk" class="form-label"></label>
|
||||
<select asp-for="Partner.IdCountryFk" class="form-control select2" asp-items="ViewBag.IdCountryFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.City" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Partner.City" class="form-control" />
|
||||
<span asp-validation-for="Partner.City" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.Street" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Partner.Street" class="form-control" />
|
||||
<span asp-validation-for="Partner.Street" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.HouseNumber" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Partner.HouseNumber" class="form-control" />
|
||||
<span asp-validation-for="Partner.HouseNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.PostNumber" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Partner.PostNumber" class="form-control" />
|
||||
<span asp-validation-for="Partner.PostNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.Post" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Partner.Post" class="form-control" />
|
||||
<span asp-validation-for="Partner.Post" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.TaxNumber" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Partner.TaxNumber" class="form-control" />
|
||||
<span asp-validation-for="Partner.TaxNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.RegistrationNumber" class="form-label"></label>
|
||||
<input autocomplete="false" asp-for="Partner.RegistrationNumber" class="form-control" />
|
||||
<span asp-validation-for="Partner.RegistrationNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<label asp-for="Partner.Email" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Partner.Email" class="form-control" />
|
||||
<span asp-validation-for="Partner.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Partner.Buyer" /> @Html.DisplayNameFor(model => model.Partner.Buyer)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Partner.Supplier" /> @Html.DisplayNameFor(model => model.Partner.Supplier)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Dodaj partnerja</button>
|
||||
<a asp-page="Index" 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");}
|
||||
|
||||
<script src="~/vendor/libs/select2/select2.js" asp-append-version="true"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.select2').select2();
|
||||
});
|
||||
</script>
|
||||
}
|
||||
60
EveryThing/Pages/CodeTablePartners/Create.cshtml.cs
Normal file
60
EveryThing/Pages/CodeTablePartners/Create.cshtml.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.CodeTablePartners
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser,TransportThingUser")]
|
||||
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;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
ViewData["IdCountryFk"] = new SelectList(_context.CodeTableCountries, "IdCountry", "TranslationSlovenian");
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTablePartner Partner { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
Partner.IdCompanyFk = user.IdCompanyFk;
|
||||
Partner.Active = true;
|
||||
|
||||
_context.CodeTablePartners.Add(Partner);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
95
EveryThing/Pages/CodeTablePartners/Delete.cshtml
Normal file
95
EveryThing/Pages/CodeTablePartners/Delete.cshtml
Normal file
@@ -0,0 +1,95 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTablePartners.DeleteModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Partner</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Title)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.City)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.City)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Street)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Street)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.HouseNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.HouseNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.PostNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.PostNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Post)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Post)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.TaxNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.TaxNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.RegistrationNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.RegistrationNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Email)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Email)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Active)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Active)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Country)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Country.Code)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Company.Ceo)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Partner.IdPartner" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
64
EveryThing/Pages/CodeTablePartners/Delete.cshtml.cs
Normal file
64
EveryThing/Pages/CodeTablePartners/Delete.cshtml.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.CodeTablePartners
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser,TransportThingUser")]
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly EveryThing.Data.ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(EveryThing.Data.ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTablePartner Partner { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Partner = await _context.CodeTablePartners
|
||||
.Include(p => p.Company)
|
||||
.Include(p => p.Country).FirstOrDefaultAsync(m => m.IdPartner == id);
|
||||
|
||||
if (Partner == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Partner = await _context.CodeTablePartners.FindAsync(id);
|
||||
|
||||
if (Partner != null)
|
||||
{
|
||||
_context.CodeTablePartners.Remove(Partner);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
92
EveryThing/Pages/CodeTablePartners/Details.cshtml
Normal file
92
EveryThing/Pages/CodeTablePartners/Details.cshtml
Normal file
@@ -0,0 +1,92 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTablePartners.DetailsModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>Partner</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Title)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.City)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.City)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Street)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Street)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.HouseNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.HouseNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.PostNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.PostNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Post)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Post)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.TaxNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.TaxNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.RegistrationNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.RegistrationNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Email)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Email)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Active)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Active)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Country)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Country.Code)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Partner.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Partner.Company.Ceo)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Partner.IdPartner">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
45
EveryThing/Pages/CodeTablePartners/Details.cshtml.cs
Normal file
45
EveryThing/Pages/CodeTablePartners/Details.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;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.CodeTablePartners
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser,TransportThingUser")]
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly EveryThing.Data.ApplicationDbContext _context;
|
||||
|
||||
public DetailsModel(EveryThing.Data.ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public CodeTablePartner Partner { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Partner = await _context.CodeTablePartners
|
||||
.Include(p => p.Company)
|
||||
.Include(p => p.Country).FirstOrDefaultAsync(m => m.IdPartner == id);
|
||||
|
||||
if (Partner == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
130
EveryThing/Pages/CodeTablePartners/Edit.cshtml
Normal file
130
EveryThing/Pages/CodeTablePartners/Edit.cshtml
Normal file
@@ -0,0 +1,130 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTablePartners.EditModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Urejanje partnerja";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
<link rel="stylesheet" href="~/vendor/libs/select2/select2.css" asp-append-version="true" />
|
||||
|
||||
<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">Partnerji /</span> Urejanje
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki podjetja
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="Partner.IdPartner" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.Title" class="form-label"></label>
|
||||
<input asp-for="Partner.Title" class="form-control" />
|
||||
<span asp-validation-for="Partner.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.IdCountryFk" class="form-label"></label>
|
||||
<select asp-for="Partner.IdCountryFk" class="form-control select2" asp-items="ViewBag.IdCountryFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.City" class="form-label"></label>
|
||||
<input asp-for="Partner.City" class="form-control" />
|
||||
<span asp-validation-for="Partner.City" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.Street" class="form-label"></label>
|
||||
<input asp-for="Partner.Street" class="form-control" />
|
||||
<span asp-validation-for="Partner.Street" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.HouseNumber" class="form-label"></label>
|
||||
<input asp-for="Partner.HouseNumber" class="form-control" />
|
||||
<span asp-validation-for="Partner.HouseNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.PostNumber" class="form-label"></label>
|
||||
<input asp-for="Partner.PostNumber" class="form-control" />
|
||||
<span asp-validation-for="Partner.PostNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.Post" class="form-label"></label>
|
||||
<input asp-for="Partner.Post" class="form-control" />
|
||||
<span asp-validation-for="Partner.Post" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.TaxNumber" class="form-label"></label>
|
||||
<input asp-for="Partner.TaxNumber" class="form-control" />
|
||||
<span asp-validation-for="Partner.TaxNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.RegistrationNumber" class="form-label"></label>
|
||||
<input asp-for="Partner.RegistrationNumber" class="form-control" />
|
||||
<span asp-validation-for="Partner.RegistrationNumber" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Partner.Email" class="form-label"></label>
|
||||
<input asp-for="Partner.Email" class="form-control" />
|
||||
<span asp-validation-for="Partner.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Partner.Buyer" /> @Html.DisplayNameFor(model => model.Partner.Buyer)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Partner.Supplier" /> @Html.DisplayNameFor(model => model.Partner.Supplier)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Partner.Active" /> @Html.DisplayNameFor(model => model.Partner.Active)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Shrani</button>
|
||||
<a asp-page="Index" 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");}
|
||||
|
||||
<script src="~/vendor/libs/select2/select2.js" asp-append-version="true"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.select2').select2();
|
||||
});
|
||||
</script>
|
||||
}
|
||||
105
EveryThing/Pages/CodeTablePartners/Edit.cshtml.cs
Normal file
105
EveryThing/Pages/CodeTablePartners/Edit.cshtml.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
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;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.CodeTablePartners
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser,TransportThingUser")]
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public EditModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public CodeTablePartner Partner { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Partner = await _context.CodeTablePartners.Include(p => p.Country).FirstOrDefaultAsync(m => m.IdPartner == id);
|
||||
ViewData["IdPartner"] = id;
|
||||
|
||||
if (Partner == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewData["IdCountryFk"] = new SelectList(_context.CodeTableCountries, "IdCountry", "TranslationSlovenian");
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
var tempParter = _context.CodeTablePartners.Single(x => x.IdPartner == Partner.IdPartner);
|
||||
|
||||
if (tempParter == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
tempParter.Title = Partner.Title;
|
||||
tempParter.IdCountryFk = Partner.IdCountryFk;
|
||||
tempParter.City = Partner.City;
|
||||
tempParter.Street = Partner.Street;
|
||||
tempParter.HouseNumber = Partner.HouseNumber;
|
||||
tempParter.PostNumber = Partner.PostNumber;
|
||||
tempParter.Post = Partner.Post;
|
||||
tempParter.TaxNumber = Partner.TaxNumber;
|
||||
tempParter.RegistrationNumber = Partner.RegistrationNumber;
|
||||
tempParter.Supplier = Partner.Supplier;
|
||||
tempParter.Buyer = Partner.Buyer;
|
||||
tempParter.Active = Partner.Active;
|
||||
tempParter.Email = Partner.Email;
|
||||
|
||||
//TODO: Mogoče
|
||||
//_context.Entry(newsPost).CurrentValues.SetValues(tempPartner);
|
||||
//_context.Attach(tempPartner).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!PartnerExists(Partner.IdPartner))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool PartnerExists(int id)
|
||||
{
|
||||
return _context.CodeTablePartners.Any(e => e.IdPartner == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
110
EveryThing/Pages/CodeTablePartners/Index.cshtml
Normal file
110
EveryThing/Pages/CodeTablePartners/Index.cshtml
Normal file
@@ -0,0 +1,110 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTablePartners.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Partnerji";
|
||||
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">Partnerji /</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["InactivePartners"]> <span>Neaktivni partnerji</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<h6 class="card-header">
|
||||
Seznam partnerjev
|
||||
</h6>
|
||||
|
||||
<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Partner[0].Title)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Partner[0].Street)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Partner[0].Post)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Partner[0].IdCountryFk)
|
||||
</th>
|
||||
<th style="width: 140px;">
|
||||
@Html.DisplayNameFor(model => model.Partner[0].TaxNumber)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Partner[0].Email)
|
||||
</th>
|
||||
<th style="width: 80px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Partner)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
@if (!item.Active)
|
||||
{<span class='badge badge-danger'>Neaktivno</span>}
|
||||
</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.Country.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.TaxNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Email)
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdPartner" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="card-footer py-3 text-right">
|
||||
<a asp-page="Create" class="btn btn-primary">Vnos partnerja</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||
</script>
|
||||
}
|
||||
53
EveryThing/Pages/CodeTablePartners/Index.cshtml.cs
Normal file
53
EveryThing/Pages/CodeTablePartners/Index.cshtml.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.CodeTablePartners
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser,TransportThingUser")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly EveryThing.Data.ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public IndexModel(EveryThing.Data.ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public IList<CodeTablePartner> Partner { get;set; }
|
||||
|
||||
public async Task OnGetAsync(string searchString)
|
||||
{
|
||||
ViewData["SearchString"] = searchString;
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
Partner = await _context.CodeTablePartners
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.Include(p => p.Country)
|
||||
.Include(c => c.Company)
|
||||
.OrderBy(x => x.Title).ToListAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
Partner = Partner.Where(x => (x.Title != null && x.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase))
|
||||
|| (x.Post != null && x.Post.Contains(searchString, StringComparison.InvariantCultureIgnoreCase))
|
||||
|| (x.Street != null && x.Street.Contains(searchString, StringComparison.InvariantCultureIgnoreCase))
|
||||
|| (x.TaxNumber != null && x.TaxNumber.Contains(searchString, StringComparison.InvariantCultureIgnoreCase)))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
@model EveryThing.Pages.CodeTableVehicleFuelTypes.IndexModel.AddEditCodeTableVehicleFuelType
|
||||
|
||||
<div class="modal" tabindex="-1" role="dialog" id="divModalAddEditCodeTableVehicleFuelType">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="modalAddEditCodeTableVehicleFuelTypeTitle">Dodajanje novega artikla</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input id="inpModalAddEditCodeTableVehicleFuelTypeIdCodeTableVehicleFuelType" type="hidden" asp-for="@Model.IdVehicleFuelType" />
|
||||
<input id="inpModalAddEditCodeTableVehicleFuelTypeEdit" type="hidden" asp-for="@Model.Edit" />
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFuelType.Title" class="control-label"></label>
|
||||
<input id="inpModalAddEditCodeTableVehicleFuelTypeTitle" asp-for="VehicleFuelType.Title" class="form-control" />
|
||||
<span asp-validation-for="VehicleFuelType.Title" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="btnModalAddEditCodeTableVehicleFuelTypeConfirm" type="button" class="btn btn-primary">Shrani</button>
|
||||
<button id="btnModalAddEditCodeTableVehicleFuelTypeCancel" type="button" class="btn btn-secondary">Prekliči</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
103
EveryThing/Pages/CodeTableVehicleFuelTypes/Index.cshtml
Normal file
103
EveryThing/Pages/CodeTableVehicleFuelTypes/Index.cshtml
Normal file
@@ -0,0 +1,103 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableVehicleFuelTypes.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
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">Vrste goriva /</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 id="btnSubmit" 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="finishedProjects" @ViewData["FinishedProjects"]> <span>Aktivni artikli</span>
|
||||
</label>
|
||||
</div>*@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFuelTypes[0].Title)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.VehicleFuelTypes)
|
||||
{
|
||||
<tr data-idCodeTableVehicleFuelType="@item.IdVehicleFuelType">
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="editCodeTableVehicleFuelType(this);" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteCodeTableVehicleFuelType(this)"><i class="fas fa-times"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="button" class="btn btn-primary" onclick="addNewCodeTableVehicleFuelType();" >Vnos nove vrste</button>
|
||||
</div>
|
||||
<div id="divModalCodeTableVehicleFuelTypeAddEditPlaceholder"></div>
|
||||
</div>
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts {
|
||||
|
||||
<script src="~/js/codeTableVehicleFuelTypeHelper.js" asp-append-version="true"></script>
|
||||
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||
|
||||
function addNewCodeTableVehicleFuelType() {
|
||||
codeTableVehicleFuelTypeAddEdit('#divModalCodeTableVehicleFuelTypeAddEditPlaceholder', false, null, (idCodeTableVehicleFuelType) => {
|
||||
document.getElementById('btnSubmit').click();
|
||||
});
|
||||
}
|
||||
|
||||
function editCodeTableVehicleFuelType(element) {
|
||||
let idCodeTableVehicleFuelType = parseInt($(element).parent().parent().attr('data-idCodeTableVehicleFuelType'));
|
||||
|
||||
codeTableVehicleFuelTypeAddEdit('#divModalCodeTableVehicleFuelTypeAddEditPlaceholder', true, idCodeTableVehicleFuelType, (idCodeTableVehicleFuelType) => {
|
||||
document.getElementById('btnSubmit').click();
|
||||
});
|
||||
}
|
||||
|
||||
function deleteCodeTableVehicleFuelType(element) {
|
||||
let row = $(element).parent().parent();
|
||||
let idCodeTableVehicleFuelType = parseInt(row.attr('data-idCodeTableVehicleFuelType'));
|
||||
|
||||
codeTableVehicleFuelTypeDelete(idCodeTableVehicleFuelType, (idCodeTableVehicleFuelType) => {
|
||||
row.remove();
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
||||
176
EveryThing/Pages/CodeTableVehicleFuelTypes/Index.cshtml.cs
Normal file
176
EveryThing/Pages/CodeTableVehicleFuelTypes/Index.cshtml.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
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.Vehicle;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableVehicleFuelTypes
|
||||
{
|
||||
[Authorize(Roles = "Administrator,TransportThingUser")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
public class AddEditCodeTableVehicleFuelType
|
||||
{
|
||||
public VehicleFuelType VehicleFuelType { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
public int IdVehicleFuelType { get; set; }
|
||||
}
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public IndexModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
public IList<VehicleFuelType> VehicleFuelTypes { get;set; }
|
||||
|
||||
public async Task OnGetAsync(string searchString)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ViewData["SearchString"] = searchString;
|
||||
|
||||
VehicleFuelTypes = await _context.VehicleFuelTypes
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.Include(j => j.Company).ToListAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
VehicleFuelTypes = VehicleFuelTypes.Where(s => s.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase)
|
||||
|| (s.Title != null && s.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase))).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IActionResult OnGetCodeTableVehicleFuelTypeModal(bool edit, int idVehicleFuelType)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
VehicleFuelType vehicleFuelType = null;
|
||||
|
||||
if (edit)
|
||||
{
|
||||
vehicleFuelType = _context.VehicleFuelTypes
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdVehicleFuelType == idVehicleFuelType);
|
||||
}
|
||||
|
||||
vehicleFuelType ??= new VehicleFuelType();
|
||||
|
||||
return Partial("AddEditIVehicleFuelTypeModal", new AddEditCodeTableVehicleFuelType
|
||||
{
|
||||
VehicleFuelType = vehicleFuelType,
|
||||
Edit = edit,
|
||||
IdVehicleFuelType = idVehicleFuelType
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetCodeTableVehicleFuelType(int idVehicleFuelType)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var successful = true;
|
||||
var error = "";
|
||||
var inUse = false;
|
||||
|
||||
var vehicleFuelType = _context.VehicleFuelTypes
|
||||
.Include(x => x.VehicleFuelTypeVehicle)
|
||||
.Include(x => x.VehicleFuelTypeVehicleFueling)
|
||||
.FirstOrDefault(x => x.IdVehicleFuelType == idVehicleFuelType
|
||||
&& x.IdCompanyFk == user.IdCompanyFk);
|
||||
|
||||
if (vehicleFuelType == null)
|
||||
{
|
||||
successful = false;
|
||||
error = $"Code-table vehicle fuel type with ID: {idVehicleFuelType} not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
inUse = vehicleFuelType.VehicleFuelTypeVehicle.Count > 0 || vehicleFuelType.VehicleFuelTypeVehicleFueling.Count > 0;
|
||||
//Cene se json zacikla neki IDK.
|
||||
vehicleFuelType.VehicleFuelTypeVehicle = null;
|
||||
vehicleFuelType.VehicleFuelTypeVehicleFueling = null;
|
||||
}
|
||||
|
||||
return new JsonResult(new { vehicleFuelType, error, successful, inUse });
|
||||
}
|
||||
|
||||
public IActionResult OnPostCodeTableVehicleFuelType(string title, bool edit, int idVehicleFuelType)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
var successful = true;
|
||||
var error = "";
|
||||
|
||||
if (edit)
|
||||
{
|
||||
var vehicleFuelType = _context.VehicleFuelTypes
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdVehicleFuelType == idVehicleFuelType);
|
||||
|
||||
if (vehicleFuelType != null)
|
||||
{
|
||||
vehicleFuelType.Title = title;
|
||||
|
||||
_context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Code-table vehicle fuel type with ID: {idVehicleFuelType} not found";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var vehicleFuelType = new VehicleFuelType
|
||||
{
|
||||
Title = title,
|
||||
IdCompanyFk = user.IdCompanyFk
|
||||
};
|
||||
_context.VehicleFuelTypes.Add(vehicleFuelType);
|
||||
_context.SaveChanges();
|
||||
|
||||
idVehicleFuelType = vehicleFuelType.IdVehicleFuelType;
|
||||
}
|
||||
|
||||
return new JsonResult(new { idVehicleFuelType, error, successful });
|
||||
}
|
||||
|
||||
public IActionResult OnDeleteCodeTableVehicleFuelType(int idVehicleFuelType)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
var successful = true;
|
||||
var error = "";
|
||||
|
||||
var vehicleFuelType = _context.VehicleFuelTypes
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdVehicleFuelType == idVehicleFuelType);
|
||||
if (vehicleFuelType != null)
|
||||
{
|
||||
_context.VehicleFuelTypes.Remove(vehicleFuelType);
|
||||
_context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Code-table vehicle fuel type with ID: {idVehicleFuelType} not found";
|
||||
}
|
||||
|
||||
return new JsonResult(new { idVehicleFuelType, error, successful });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
111
EveryThing/Pages/CodeTableVehicles/CreateEdit.cshtml
Normal file
111
EveryThing/Pages/CodeTableVehicles/CreateEdit.cshtml
Normal file
@@ -0,0 +1,111 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableVehicles.CreateEditModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
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">
|
||||
Vozni park /
|
||||
</span> @if ((bool)ViewData["Edit"])
|
||||
{
|
||||
<span>Urejanje</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Nov</span>
|
||||
}
|
||||
</span>
|
||||
</h4>
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki vozila
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="@ViewData["Edit"]" name="type"/>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.Title" class="control-label"></label>
|
||||
<input asp-for="Vehicle.Title" class="form-control"/>
|
||||
<span asp-validation-for="Vehicle.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.IdMakeFk" class="control-label"></label>
|
||||
<select asp-for="Vehicle.IdMakeFk" class="form-control" asp-items="ViewBag.VehicleMake"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.Model" class="control-label"></label>
|
||||
<input asp-for="Vehicle.Model" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.RegistrationNumber" class="control-label"></label>
|
||||
<input asp-for="Vehicle.RegistrationNumber" class="form-control"/>
|
||||
<span asp-validation-for="Vehicle.RegistrationNumber" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.IdVehicleTypeFk" class="control-label"></label>
|
||||
<select asp-for="Vehicle.IdVehicleTypeFk" class="form-control" asp-items="ViewBag.VehicleType"></select>
|
||||
<span asp-validation-for="Vehicle.IdVehicleTypeFk" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Vehicle.Active"/> @Html.DisplayNameFor(model => model.Vehicle.Active)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.Year" class="control-label"></label>
|
||||
<input asp-for="Vehicle.Year" class="form-control" />
|
||||
<span asp-validation-for="Vehicle.Year" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.VinNumber" class="control-label"></label>
|
||||
<input asp-for="Vehicle.VinNumber" class="form-control" />
|
||||
<span asp-validation-for="Vehicle.VinNumber" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.EngineNumber" class="control-label"></label>
|
||||
<input asp-for="Vehicle.EngineNumber" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.IdFuelTypeFk" class="control-label"></label>
|
||||
<select asp-for="Vehicle.IdFuelTypeFk" class="form-control" asp-items="ViewBag.FuelType"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.VehicleMeterType" class="control-label"></label>
|
||||
<select asp-for="Vehicle.VehicleMeterType" class="form-control" asp-items="Html.GetEnumSelectList<Models.Vehicle.VehicleMeterType>()"></select>
|
||||
<span asp-validation-for="Vehicle.VehicleMeterType" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Vehicle.IdDepartementFk" class="control-label"></label>
|
||||
<select asp-for="Vehicle.IdDepartementFk" class="form-control" asp-items="ViewBag.Department"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<label asp-for="Vehicle.Note" class="control-label"></label>
|
||||
@Html.TextAreaFor(model => model.Vehicle.Note, new { @class = "form-control", style = "resize:none; height: 455px;"})
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top:10px;">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Shrani" class="btn btn-primary" />
|
||||
<a class="btn btn-default" asp-page="./Index">Nazaj na seznam</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
109
EveryThing/Pages/CodeTableVehicles/CreateEdit.cshtml.cs
Normal file
109
EveryThing/Pages/CodeTableVehicles/CreateEdit.cshtml.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
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 EveryThing.Models.Vehicle;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using NuGet.Protocol.Plugins;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableVehicles
|
||||
{
|
||||
[Authorize(Roles = "Administrator,TransportThingUser")]
|
||||
public class CreateEditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public CreateEditModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Vehicle Vehicle { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(bool edit, int? id)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
ViewData["Edit"] = edit;
|
||||
|
||||
if (edit)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Vehicle = await _context.Vehicles.FirstOrDefaultAsync(x => x.IdCompanyFk == user.IdCompanyFk
|
||||
&& x.IdVehicle == id);
|
||||
if (Vehicle == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
ViewData["VehicleType"] = new SelectList(_context.VehicleTypes
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active), "IdVehicleType", "Title");
|
||||
|
||||
ViewData["VehicleMake"] = new SelectList(_context.VehicleMakes
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active), "IdVehicleMake", "Title");
|
||||
|
||||
ViewData["FuelType"] = new SelectList(_context.VehicleFuelTypes
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk), "IdVehicleFuelType", "Title");
|
||||
|
||||
ViewData["Department"] = new SelectList(_context.CodeTableDepartements
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk), "IdDepartement", "Title");
|
||||
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
// To protect from over-posting attacks, see https://aka.ms/RazorPagesCRUD
|
||||
public async Task<IActionResult> OnPostAsync(bool edit)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
if (edit)
|
||||
{
|
||||
_context.Attach(Vehicle).State = EntityState.Modified;
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!VehicleExists(Vehicle.IdVehicle))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add new
|
||||
_context.Vehicles.Add(Vehicle);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool VehicleExists(int id)
|
||||
{
|
||||
return _context.Vehicles.Any(e => e.IdVehicle == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
139
EveryThing/Pages/CodeTableVehicles/Index.cshtml
Normal file
139
EveryThing/Pages/CodeTableVehicles/Index.cshtml
Normal file
@@ -0,0 +1,139 @@
|
||||
@page
|
||||
@model EveryThing.Pages.CodeTableVehicles.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
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">Vozni park / </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" asp-route-type="@ViewData["Type"]">
|
||||
<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="inactiveVehicles" @ViewData["InactiveVehicles"]> <span>Neaktivna vozila</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
|
||||
<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@*<th style="width: 200px;">#</th>*@
|
||||
<th style="width: auto;">
|
||||
@Html.DisplayNameFor(modelItem => modelItem.Vehicles[0].Title)
|
||||
</th>
|
||||
<th style="width: auto;">
|
||||
@Html.DisplayNameFor(modelItem => modelItem.Vehicles[0].RegistrationNumber)
|
||||
</th>
|
||||
<th style="width: 100px">
|
||||
@Html.DisplayNameFor(modelItem => modelItem.Vehicles[0].Active)
|
||||
</th>
|
||||
<th style="width: 120px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Vehicles)
|
||||
{
|
||||
<tr data-idvehicle="@item.IdVehicle">
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.RegistrationNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Active)
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="true" asp-route-id="@item.IdVehicle" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteVehicle(this)"><i class="fas fa-times"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="card-footer py-3 text-right">
|
||||
<a asp-page="CreateEdit" asp-route-edit="false" class="btn btn-primary">Vnos novega</a>
|
||||
</div>
|
||||
</div>
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({ container: 'table' });
|
||||
|
||||
function deleteVehicle(element) {
|
||||
let row = $(element).parent().parent();
|
||||
let idInvoice = $(row).attr('data-idinvoice');
|
||||
let invoiceNumber = $(row).attr('data-number');
|
||||
|
||||
Swal.fire({
|
||||
title: `Izbrišem dokument ${invoiceNumber}?`,
|
||||
text: "Tega dejanja ni možno razveljaviti!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Da, izbriši!',
|
||||
cancelButtonText: 'Prekliči!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.blockUI();
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "/Invoices/Index/?handler=Invoice",
|
||||
data: {
|
||||
idInvoice
|
||||
},
|
||||
success: function (data) {
|
||||
$.unblockUI();
|
||||
if (data.successful) {
|
||||
$(row).remove();
|
||||
} else {
|
||||
console.log(data);
|
||||
Swal.fire('Napaka pri brisanju dokumenta',
|
||||
data.error,
|
||||
'error');
|
||||
}
|
||||
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
51
EveryThing/Pages/CodeTableVehicles/Index.cshtml.cs
Normal file
51
EveryThing/Pages/CodeTableVehicles/Index.cshtml.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
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.Vehicle;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using EveryThing.Models.Invoice;
|
||||
|
||||
namespace EveryThing.Pages.CodeTableVehicles
|
||||
{
|
||||
[Authorize(Roles = "Administrator,TransportThingUser")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public IndexModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public IList<Vehicle> Vehicles { get;set; }
|
||||
|
||||
public async Task OnGetAsync(string searchString, string inactiveVehicles)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ViewData["SearchString"] = searchString;
|
||||
ViewData["InactiveVehicles"] = inactiveVehicles == "on" ? "checked" : "";
|
||||
|
||||
Vehicles = await _context.Vehicles
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.OrderBy(x => x.Active)
|
||||
.ThenBy(x => x.Title)
|
||||
.ToListAsync();
|
||||
|
||||
// Search string
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
Vehicles = Vehicles.Where(s => s.Title.Contains(searchString)).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
EveryThing/Pages/Documents/Create.cshtml
Normal file
57
EveryThing/Pages/Documents/Create.cshtml
Normal file
@@ -0,0 +1,57 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Documents.CreateModel
|
||||
|
||||
<h4>Document</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.IdDocumentTypeFk" class="control-label"></label>
|
||||
<select asp-for="Document.IdDocumentTypeFk" class ="form-control" asp-items="ViewBag.IdDocumentTypeFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.IdReferenceFk" class="control-label"></label>
|
||||
<input asp-for="Document.IdReferenceFk" class="form-control" />
|
||||
<span asp-validation-for="Document.IdReferenceFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.ExpirationDate" class="control-label"></label>
|
||||
<input asp-for="Document.ExpirationDate" class="form-control" />
|
||||
<span asp-validation-for="Document.ExpirationDate" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.Number" class="control-label"></label>
|
||||
<input asp-for="Document.Number" class="form-control" />
|
||||
<span asp-validation-for="Document.Number" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.Reference" class="control-label"></label>
|
||||
<input asp-for="Document.Reference" class="form-control" />
|
||||
<span asp-validation-for="Document.Reference" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.Note" class="control-label"></label>
|
||||
<input asp-for="Document.Note" class="form-control" />
|
||||
<span asp-validation-for="Document.Note" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Document.Active" /> @Html.DisplayNameFor(model => model.Document.Active)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
46
EveryThing/Pages/Documents/Create.cshtml.cs
Normal file
46
EveryThing/Pages/Documents/Create.cshtml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Documents
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public CreateModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
ViewData["IdDocumentTypeFk"] = new SelectList(_context.DocumentTypes, "IdDocumentType", "Title");
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Document Document { get; set; }
|
||||
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Documents.Add(Document);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
58
EveryThing/Pages/Documents/Delete.cshtml
Normal file
58
EveryThing/Pages/Documents/Delete.cshtml
Normal file
@@ -0,0 +1,58 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Documents.DeleteModel
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Document</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.IdReferenceFk)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.IdReferenceFk)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.ExpirationDate)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.ExpirationDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.Number)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.Number)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.Reference)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.Reference)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.Note)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.Note)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.Active)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.Active)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.DocumentType)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.DocumentType.Title)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Document.IdDocument" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
60
EveryThing/Pages/Documents/Delete.cshtml.cs
Normal file
60
EveryThing/Pages/Documents/Delete.cshtml.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Documents
|
||||
{
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Document Document { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Document = await _context.Documents
|
||||
.Include(d => d.DocumentType).FirstOrDefaultAsync(m => m.IdDocument == id);
|
||||
|
||||
if (Document == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Document = await _context.Documents.FindAsync(id);
|
||||
|
||||
if (Document != null)
|
||||
{
|
||||
_context.Documents.Remove(Document);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
55
EveryThing/Pages/Documents/Details.cshtml
Normal file
55
EveryThing/Pages/Documents/Details.cshtml
Normal file
@@ -0,0 +1,55 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Documents.DetailsModel
|
||||
|
||||
<div>
|
||||
<h4>Document</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.IdReferenceFk)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.IdReferenceFk)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.ExpirationDate)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.ExpirationDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.Number)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.Number)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.Reference)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.Reference)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.Note)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.Note)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.Active)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.Active)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Document.DocumentType)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Document.DocumentType.Title)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Document.IdDocument">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
41
EveryThing/Pages/Documents/Details.cshtml.cs
Normal file
41
EveryThing/Pages/Documents/Details.cshtml.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Documents
|
||||
{
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DetailsModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Document Document { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Document = await _context.Documents
|
||||
.Include(d => d.DocumentType).FirstOrDefaultAsync(m => m.IdDocument == id);
|
||||
|
||||
if (Document == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
59
EveryThing/Pages/Documents/Edit.cshtml
Normal file
59
EveryThing/Pages/Documents/Edit.cshtml
Normal file
@@ -0,0 +1,59 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Documents.EditModel
|
||||
|
||||
<h4>Document</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Document.IdDocument" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.IdDocumentTypeFk" class="control-label"></label>
|
||||
<select asp-for="Document.IdDocumentTypeFk" class="form-control" asp-items="ViewBag.IdDocumentTypeFk"></select>
|
||||
<span asp-validation-for="Document.IdDocumentTypeFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.IdReferenceFk" class="control-label"></label>
|
||||
<input asp-for="Document.IdReferenceFk" class="form-control" />
|
||||
<span asp-validation-for="Document.IdReferenceFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.ExpirationDate" class="control-label"></label>
|
||||
<input asp-for="Document.ExpirationDate" class="form-control" />
|
||||
<span asp-validation-for="Document.ExpirationDate" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.Number" class="control-label"></label>
|
||||
<input asp-for="Document.Number" class="form-control" />
|
||||
<span asp-validation-for="Document.Number" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.Reference" class="control-label"></label>
|
||||
<input asp-for="Document.Reference" class="form-control" />
|
||||
<span asp-validation-for="Document.Reference" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Document.Note" class="control-label"></label>
|
||||
<input asp-for="Document.Note" class="form-control" />
|
||||
<span asp-validation-for="Document.Note" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="Document.Active" /> @Html.DisplayNameFor(model => model.Document.Active)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
79
EveryThing/Pages/Documents/Edit.cshtml.cs
Normal file
79
EveryThing/Pages/Documents/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;
|
||||
|
||||
namespace EveryThing.Pages.Documents
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public EditModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Document Document { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Document = await _context.Documents
|
||||
.Include(d => d.DocumentType).FirstOrDefaultAsync(m => m.IdDocument == id);
|
||||
|
||||
if (Document == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["IdDocumentTypeFk"] = new SelectList(_context.DocumentTypes, "IdDocumentType", "Title");
|
||||
return Page();
|
||||
}
|
||||
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(Document).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!DocumentExists(Document.IdDocument))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool DocumentExists(int id)
|
||||
{
|
||||
return _context.Documents.Any(e => e.IdDocument == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
66
EveryThing/Pages/Documents/Index.cshtml
Normal file
66
EveryThing/Pages/Documents/Index.cshtml
Normal file
@@ -0,0 +1,66 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Documents.IndexModel
|
||||
|
||||
<p>
|
||||
<a asp-page="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Document[0].IdReferenceFk)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Document[0].ExpirationDate)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Document[0].Number)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Document[0].Reference)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Document[0].Note)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Document[0].Active)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Document[0].DocumentType)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Document) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.IdReferenceFk)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ExpirationDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Number)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Reference)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Note)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Active)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DocumentType.Title)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.IdDocument">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.IdDocument">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.IdDocument">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
52
EveryThing/Pages/Documents/Index.cshtml.cs
Normal file
52
EveryThing/Pages/Documents/Index.cshtml.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Documents
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public IndexModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IList<Document> Document { get;set; }
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
Document = _context.Documents.Include(d => d.DocumentType).ToList();
|
||||
|
||||
return Partial("IndexModal");
|
||||
}
|
||||
|
||||
//public async Task<IActionResult> OnGetAsync()
|
||||
//{
|
||||
// Document = await _context.Documents
|
||||
// .Include(d => d.DocumentType).ToListAsync();
|
||||
|
||||
// return Partial("IndexModal");
|
||||
//}
|
||||
|
||||
public IActionResult OnGetModal()
|
||||
{
|
||||
Document = _context.Documents.Include(d => d.DocumentType).ToList();
|
||||
|
||||
return Partial("IndexModal");
|
||||
}
|
||||
|
||||
//public async Task OnGetModalAsync()
|
||||
//{
|
||||
// Document = await _context.Documents
|
||||
// .Include(d => d.DocumentType).ToListAsync();
|
||||
//}
|
||||
}
|
||||
}
|
||||
67
EveryThing/Pages/Documents/IndexModal.cshtml
Normal file
67
EveryThing/Pages/Documents/IndexModal.cshtml
Normal file
@@ -0,0 +1,67 @@
|
||||
@model IList<Models.Document>
|
||||
|
||||
<p>
|
||||
<a asp-page="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model[0].IdReferenceFk)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model[0].ExpirationDate)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model[0].Number)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model[0].Reference)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model[0].Note)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model[0].Active)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model[0].DocumentType)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.IdReferenceFk)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ExpirationDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Number)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Reference)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Note)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Active)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DocumentType.Title)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.IdDocument">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.IdDocument">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.IdDocument">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
23
EveryThing/Pages/Error.cshtml
Normal file
23
EveryThing/Pages/Error.cshtml
Normal file
@@ -0,0 +1,23 @@
|
||||
@page
|
||||
@model ErrorModel
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
||||
@if (Model.ShowRequestId)
|
||||
{
|
||||
<p>
|
||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||
</p>
|
||||
}
|
||||
|
||||
<h3>Development Mode</h3>
|
||||
<p>
|
||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||
</p>
|
||||
<p>
|
||||
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
|
||||
</p>
|
||||
21
EveryThing/Pages/Error.cshtml.cs
Normal file
21
EveryThing/Pages/Error.cshtml.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace EveryThing.Pages
|
||||
{
|
||||
public class ErrorModel : PageModel
|
||||
{
|
||||
public string RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
72
EveryThing/Pages/Files/Create.cshtml
Normal file
72
EveryThing/Pages/Files/Create.cshtml
Normal file
@@ -0,0 +1,72 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Files.CreateModel
|
||||
|
||||
<h4>File</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.IdCompanyFk" class="control-label"></label>
|
||||
<select asp-for="File.IdCompanyFk" class ="form-control" asp-items="ViewBag.IdCompanyFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.FileType" class="control-label"></label>
|
||||
<select asp-for="File.FileType" class="form-control"></select>
|
||||
<span asp-validation-for="File.FileType" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.IdReferenceFk" class="control-label"></label>
|
||||
<input asp-for="File.IdReferenceFk" class="form-control" />
|
||||
<span asp-validation-for="File.IdReferenceFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Guid" class="control-label"></label>
|
||||
<input asp-for="File.Guid" class="form-control" />
|
||||
<span asp-validation-for="File.Guid" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Extension" class="control-label"></label>
|
||||
<input asp-for="File.Extension" class="form-control" />
|
||||
<span asp-validation-for="File.Extension" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Salt" class="control-label"></label>
|
||||
<input asp-for="File.Salt" class="form-control" />
|
||||
<span asp-validation-for="File.Salt" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Iv" class="control-label"></label>
|
||||
<input asp-for="File.Iv" class="form-control" />
|
||||
<span asp-validation-for="File.Iv" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Title" class="control-label"></label>
|
||||
<input asp-for="File.Title" class="form-control" />
|
||||
<span asp-validation-for="File.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.DateOfUpload" class="control-label"></label>
|
||||
<input asp-for="File.DateOfUpload" class="form-control" />
|
||||
<span asp-validation-for="File.DateOfUpload" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Note" class="control-label"></label>
|
||||
<input asp-for="File.Note" class="form-control" />
|
||||
<span asp-validation-for="File.Note" 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-page="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
46
EveryThing/Pages/Files/Create.cshtml.cs
Normal file
46
EveryThing/Pages/Files/Create.cshtml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Files
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public CreateModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Ceo");
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public new File File { get; set; }
|
||||
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Files.Add(File);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
76
EveryThing/Pages/Files/Delete.cshtml
Normal file
76
EveryThing/Pages/Files/Delete.cshtml
Normal file
@@ -0,0 +1,76 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Files.DeleteModel
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>File</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.FileType)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.FileType)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.IdReferenceFk)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.IdReferenceFk)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Guid)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Guid)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Extension)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Extension)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Salt)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Salt)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Iv)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Iv)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Title)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.DateOfUpload)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.DateOfUpload)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Note)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Note)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Company.Ceo)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="File.IdFile" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
60
EveryThing/Pages/Files/Delete.cshtml.cs
Normal file
60
EveryThing/Pages/Files/Delete.cshtml.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Files
|
||||
{
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public new File File { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
File = await _context.Files
|
||||
.Include(f => f.Company).FirstOrDefaultAsync(m => m.IdFile == id);
|
||||
|
||||
if (File == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
File = await _context.Files.FindAsync(id);
|
||||
|
||||
if (File != null)
|
||||
{
|
||||
_context.Files.Remove(File);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
73
EveryThing/Pages/Files/Details.cshtml
Normal file
73
EveryThing/Pages/Files/Details.cshtml
Normal file
@@ -0,0 +1,73 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Files.DetailsModel
|
||||
|
||||
<div>
|
||||
<h4>File</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.FileType)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.FileType)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.IdReferenceFk)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.IdReferenceFk)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Guid)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Guid)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Extension)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Extension)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Salt)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Salt)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Iv)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Iv)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Title)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.DateOfUpload)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.DateOfUpload)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Note)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Note)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.File.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.File.Company.Ceo)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.File.IdFile">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
41
EveryThing/Pages/Files/Details.cshtml.cs
Normal file
41
EveryThing/Pages/Files/Details.cshtml.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Files
|
||||
{
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DetailsModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public new File File { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
File = await _context.Files
|
||||
.Include(f => f.Company).FirstOrDefaultAsync(m => m.IdFile == id);
|
||||
|
||||
if (File == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
74
EveryThing/Pages/Files/Edit.cshtml
Normal file
74
EveryThing/Pages/Files/Edit.cshtml
Normal file
@@ -0,0 +1,74 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Files.EditModel
|
||||
|
||||
<h4>File</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="File.IdFile" />
|
||||
<div class="form-group">
|
||||
<label asp-for="File.IdCompanyFk" class="control-label"></label>
|
||||
<select asp-for="File.IdCompanyFk" class="form-control" asp-items="ViewBag.IdCompanyFk"></select>
|
||||
<span asp-validation-for="File.IdCompanyFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.FileType" class="control-label"></label>
|
||||
<select asp-for="File.FileType" class="form-control"></select>
|
||||
<span asp-validation-for="File.FileType" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.IdReferenceFk" class="control-label"></label>
|
||||
<input asp-for="File.IdReferenceFk" class="form-control" />
|
||||
<span asp-validation-for="File.IdReferenceFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Guid" class="control-label"></label>
|
||||
<input asp-for="File.Guid" class="form-control" />
|
||||
<span asp-validation-for="File.Guid" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Extension" class="control-label"></label>
|
||||
<input asp-for="File.Extension" class="form-control" />
|
||||
<span asp-validation-for="File.Extension" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Salt" class="control-label"></label>
|
||||
<input asp-for="File.Salt" class="form-control" />
|
||||
<span asp-validation-for="File.Salt" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Iv" class="control-label"></label>
|
||||
<input asp-for="File.Iv" class="form-control" />
|
||||
<span asp-validation-for="File.Iv" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Title" class="control-label"></label>
|
||||
<input asp-for="File.Title" class="form-control" />
|
||||
<span asp-validation-for="File.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.DateOfUpload" class="control-label"></label>
|
||||
<input asp-for="File.DateOfUpload" class="form-control" />
|
||||
<span asp-validation-for="File.DateOfUpload" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="File.Note" class="control-label"></label>
|
||||
<input asp-for="File.Note" class="form-control" />
|
||||
<span asp-validation-for="File.Note" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
79
EveryThing/Pages/Files/Edit.cshtml.cs
Normal file
79
EveryThing/Pages/Files/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;
|
||||
|
||||
namespace EveryThing.Pages.Files
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public EditModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public new File File { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
File = await _context.Files
|
||||
.Include(f => f.Company).FirstOrDefaultAsync(m => m.IdFile == id);
|
||||
|
||||
if (File == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Ceo");
|
||||
return Page();
|
||||
}
|
||||
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(File).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!FileExists(File.IdFile))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool FileExists(int id)
|
||||
{
|
||||
return _context.Files.Any(e => e.IdFile == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
84
EveryThing/Pages/Files/Index.cshtml
Normal file
84
EveryThing/Pages/Files/Index.cshtml
Normal file
@@ -0,0 +1,84 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Files.IndexModel
|
||||
|
||||
<p>
|
||||
<a asp-page="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].FileType)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].IdReferenceFk)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].Guid)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].Extension)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].Salt)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].Iv)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].Title)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].DateOfUpload)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].Note)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.File[0].Company)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.File) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FileType)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.IdReferenceFk)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Guid)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Extension)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Salt)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Iv)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOfUpload)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Note)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Company.Ceo)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.IdFile">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.IdFile">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.IdFile">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
29
EveryThing/Pages/Files/Index.cshtml.cs
Normal file
29
EveryThing/Pages/Files/Index.cshtml.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Files
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public IndexModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public new IList<File> File { get;set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
File = await _context.Files.Include(f => f.Company).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
51
EveryThing/Pages/Files/Upload.cshtml
Normal file
51
EveryThing/Pages/Files/Upload.cshtml
Normal file
@@ -0,0 +1,51 @@
|
||||
@page
|
||||
@using EveryThing.Models.Project
|
||||
@model EveryThing.Pages.Files.UploadModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Prilaganje datotek";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
|
||||
<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">Datoteke /</span> Prilaganje
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki pozicije
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="IdReferenceFk" name="idReferenceFk" />
|
||||
<input type="hidden" asp-for="FileTypeInt" name="fileTypeInt" />
|
||||
<input type="hidden" asp-for="Referer" name="referer" />
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<input type="file" name="postedFiles" multiple/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<input type="submit" class="btn btn-primary" value="Naloži" asp-page-handler="Upload" />
|
||||
<a href="@Model.Referer" 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");}
|
||||
}
|
||||
214
EveryThing/Pages/Files/Upload.cshtml.cs
Normal file
214
EveryThing/Pages/Files/Upload.cshtml.cs
Normal file
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EveryThing.Pages.Files
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class UploadModel : PageModel
|
||||
{
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public UploadModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager, IWebHostEnvironment environment)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
_hostingEnvironment = environment;
|
||||
}
|
||||
|
||||
|
||||
[BindProperty]
|
||||
public IFormFile File { get; set; }
|
||||
[BindProperty]
|
||||
public int IdReferenceFk { get; set; }
|
||||
[BindProperty]
|
||||
public int FileTypeInt { get; set; }
|
||||
public string Referer { get; set; }
|
||||
|
||||
public IActionResult OnGet(int idReferenceFk, FileType fileType)
|
||||
{
|
||||
if (idReferenceFk <= 0 || (int)fileType < 0)
|
||||
return NotFound();
|
||||
|
||||
IdReferenceFk = idReferenceFk;
|
||||
FileTypeInt = (int)fileType;
|
||||
|
||||
Referer = Request.Headers["Referer"].ToString();
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostUpload(int idReferenceFk, int fileTypeInt, List<IFormFile> postedFiles, string referer)
|
||||
{
|
||||
if (postedFiles is not { Count: > 0 })
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var fileType = (FileType)fileTypeInt;
|
||||
|
||||
var path = GetFolder(user.IdCompanyFk, fileType);// Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "Files", user.IdCompanyFk.ToString(), fileTypeInt.ToString());
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
foreach (var formFile in postedFiles)
|
||||
{
|
||||
var guid = Guid.NewGuid().ToString().Replace("-", "_");
|
||||
var extension = Path.GetExtension(formFile.FileName);
|
||||
var fileName = guid + extension;
|
||||
|
||||
await using var stream = new FileStream(Path.Combine(path, fileName), FileMode.Create);
|
||||
await formFile.CopyToAsync(stream);
|
||||
|
||||
var newFile = new Models.File
|
||||
{
|
||||
IdCompanyFk = user.IdCompanyFk,
|
||||
IdReferenceFk = idReferenceFk,
|
||||
Title = formFile.FileName,
|
||||
Extension = extension,
|
||||
Guid = guid,
|
||||
Salt = "",
|
||||
Iv = "",
|
||||
DateOfUpload = DateTime.Now,
|
||||
FileType = fileType
|
||||
};
|
||||
|
||||
_context.Files.Add(newFile);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(referer))
|
||||
{
|
||||
return Redirect(referer);
|
||||
}
|
||||
|
||||
switch (fileType)
|
||||
{
|
||||
case FileType.ProjectPart:
|
||||
return RedirectToPage("/Projects/Edit", new { id = _context.ProjectParts.FirstOrDefault(x => x.IdProjectPart == idReferenceFk)!.IdProjectFk});
|
||||
case FileType.Project:
|
||||
return RedirectToPage("/Projects/Edit", new { id = idReferenceFk });
|
||||
case FileType.CodeTableItem:
|
||||
return RedirectToPage("/CodeTableItems/Index");
|
||||
default:
|
||||
return RedirectToPage("/Index");
|
||||
}
|
||||
}
|
||||
|
||||
private string GetFolder(int idCompany, FileType fileType)
|
||||
{
|
||||
//return Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "Files", idCompany.ToString(), ((int)fileType).ToString());
|
||||
return Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "Files", ((int)fileType).ToString());
|
||||
}
|
||||
|
||||
public FileResult OnGetDownloadFile(int idFile, int idReferenceFk, int fileTypeInt)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var fileType = (FileType)fileTypeInt;
|
||||
|
||||
var file = _context.Files
|
||||
.FirstOrDefault(x => x.IdCompanyFk == user.IdCompanyFk
|
||||
&& x.IdReferenceFk == idReferenceFk
|
||||
&& x.IdFile == idFile);
|
||||
|
||||
if (file == null)
|
||||
return null;
|
||||
|
||||
var path = Path.Combine(GetFolder(user.IdCompanyFk, fileType), file.Guid + file.Extension);
|
||||
|
||||
var bytes = System.IO.File.ReadAllBytes(path);
|
||||
|
||||
return File(bytes, "application/octet-stream", file.Title);
|
||||
}
|
||||
|
||||
public IActionResult OnDeleteFile(int idFile)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var file = _context.Files
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdFile == idFile);
|
||||
|
||||
if (file == null)
|
||||
{
|
||||
return new JsonResult(new { idFile, error = $"File with id {idFile} not exists!", successful = false });
|
||||
}
|
||||
|
||||
var path = Path.Combine(GetFolder(user.IdCompanyFk, file.FileType), file.Guid + file.Extension);
|
||||
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
System.IO.File.Delete(path);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// return new JsonResult(new { idFile, error = "File path not exists!", successful = false });
|
||||
//}
|
||||
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
return new JsonResult(new { idFile, error = "File was not deleted from disk!", successful = false });
|
||||
}
|
||||
|
||||
_context.Files.Remove(file);
|
||||
_context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { idFile, error = "", successful = true});
|
||||
}
|
||||
|
||||
public IActionResult OnGetFile(int idFile)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var successful = true;
|
||||
var error = "";
|
||||
var inUse = false;
|
||||
|
||||
var file = _context.Files
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdFile == idFile);
|
||||
|
||||
if (file == null)
|
||||
{
|
||||
successful = false;
|
||||
error = $"File with ID: {idFile} not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO prever in use
|
||||
inUse = false;
|
||||
}
|
||||
|
||||
return new JsonResult(new { file, error, successful, inUse });
|
||||
}
|
||||
}
|
||||
}
|
||||
93
EveryThing/Pages/FleetFueling/Create.cshtml
Normal file
93
EveryThing/Pages/FleetFueling/Create.cshtml
Normal file
@@ -0,0 +1,93 @@
|
||||
@page
|
||||
@model EveryThing.Pages.FleetFueling.CreateModel
|
||||
|
||||
<h4>VehicleFueling</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdVehicleFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdVehicleFk" class ="form-control" asp-items="ViewBag.IdVehicleFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdEmployeeFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdEmployeeFk" class ="form-control" asp-items="ViewBag.IdEmployeeFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.DateOfFueling" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.DateOfFueling" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.DateOfFueling" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdVehicleFuelingCardFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdVehicleFuelingCardFk" class ="form-control" asp-items="ViewBag.IdVehicleFuelingCardFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.FuelingCardInvoiceDate" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.FuelingCardInvoiceDate" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.FuelingCardInvoiceDate" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.FuelingCardInvoiceNumber" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.FuelingCardInvoiceNumber" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.FuelingCardInvoiceNumber" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdVehicleFuelTypeFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdVehicleFuelTypeFk" class ="form-control" asp-items="ViewBag.IdVehicleFuelTypeFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Quantity" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Quantity" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Quantity" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Mileage" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Mileage" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Mileage" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="VehicleFueling.FullTank" /> @Html.DisplayNameFor(model => model.VehicleFueling.FullTank)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Amount" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Amount" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Amount" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdCountryFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdCountryFk" class ="form-control" asp-items="ViewBag.IdCountryFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.City" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.City" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.City" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Reference" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Reference" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Reference" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Note" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Note" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Note" 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-page="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
50
EveryThing/Pages/FleetFueling/Create.cshtml.cs
Normal file
50
EveryThing/Pages/FleetFueling/Create.cshtml.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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.Vehicle;
|
||||
|
||||
namespace EveryThing.Pages.FleetFueling
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public CreateModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
ViewData["IdCountryFk"] = new SelectList(_context.CodeTableCountries, "IdCountry", "Title");
|
||||
ViewData["IdEmployeeFk"] = new SelectList(_context.CodeTableEmployees, "IdEmployee", "BankAccount");
|
||||
ViewData["IdVehicleFk"] = new SelectList(_context.Vehicles, "IdVehicle", "RegistrationNumber");
|
||||
ViewData["IdVehicleFuelTypeFk"] = new SelectList(_context.VehicleFuelTypes, "IdVehicleFuelType", "Title");
|
||||
ViewData["IdVehicleFuelingCardFk"] = new SelectList(_context.VehicleFuelingCards, "IdFuelingCard", "CardNumber");
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Models.Vehicle.VehicleFueling VehicleFueling { get; set; }
|
||||
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.VehicleFuelings.Add(VehicleFueling);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
106
EveryThing/Pages/FleetFueling/Delete.cshtml
Normal file
106
EveryThing/Pages/FleetFueling/Delete.cshtml
Normal file
@@ -0,0 +1,106 @@
|
||||
@page
|
||||
@model EveryThing.Pages.FleetFueling.DeleteModel
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>VehicleFueling</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.DateOfFueling)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.DateOfFueling)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.FuelingCardInvoiceDate)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.FuelingCardInvoiceDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.FuelingCardInvoiceNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.FuelingCardInvoiceNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Quantity)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Quantity)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Mileage)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Mileage)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.FullTank)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.FullTank)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Amount)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Amount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.City)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.City)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Reference)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Reference)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Note)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Note)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Vehicle)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Vehicle.RegistrationNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Employee)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Employee.BankAccount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Country)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Country.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.VehicleFuelingCard)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.VehicleFuelingCard.CardNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.VehicleFuelType)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.VehicleFuelType.Title)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="VehicleFueling.IdVehicleFueling" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
64
EveryThing/Pages/FleetFueling/Delete.cshtml.cs
Normal file
64
EveryThing/Pages/FleetFueling/Delete.cshtml.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
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.Vehicle;
|
||||
|
||||
namespace EveryThing.Pages.FleetFueling
|
||||
{
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Models.Vehicle.VehicleFueling VehicleFueling { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
VehicleFueling = await _context.VehicleFuelings
|
||||
.Include(v => v.Country)
|
||||
.Include(v => v.Employee)
|
||||
.Include(v => v.Vehicle)
|
||||
.Include(v => v.VehicleFuelType)
|
||||
.Include(v => v.VehicleFuelingCard).FirstOrDefaultAsync(m => m.IdVehicleFueling == id);
|
||||
|
||||
if (VehicleFueling == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
VehicleFueling = await _context.VehicleFuelings.FindAsync(id);
|
||||
|
||||
if (VehicleFueling != null)
|
||||
{
|
||||
_context.VehicleFuelings.Remove(VehicleFueling);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
103
EveryThing/Pages/FleetFueling/Details.cshtml
Normal file
103
EveryThing/Pages/FleetFueling/Details.cshtml
Normal file
@@ -0,0 +1,103 @@
|
||||
@page
|
||||
@model EveryThing.Pages.FleetFueling.DetailsModel
|
||||
|
||||
<div>
|
||||
<h4>VehicleFueling</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.DateOfFueling)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.DateOfFueling)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.FuelingCardInvoiceDate)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.FuelingCardInvoiceDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.FuelingCardInvoiceNumber)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.FuelingCardInvoiceNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Quantity)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Quantity)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Mileage)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Mileage)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.FullTank)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.FullTank)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Amount)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Amount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.City)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.City)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Reference)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Reference)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Note)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Note)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Vehicle)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Vehicle.RegistrationNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Employee)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Employee.BankAccount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.Country)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.Country.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.VehicleFuelingCard)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.VehicleFuelingCard.CardNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling.VehicleFuelType)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.VehicleFueling.VehicleFuelType.Title)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.VehicleFueling.IdVehicleFueling">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
45
EveryThing/Pages/FleetFueling/Details.cshtml.cs
Normal file
45
EveryThing/Pages/FleetFueling/Details.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.Vehicle;
|
||||
|
||||
namespace EveryThing.Pages.FleetFueling
|
||||
{
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DetailsModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Models.Vehicle.VehicleFueling VehicleFueling { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
VehicleFueling = await _context.VehicleFuelings
|
||||
.Include(v => v.Country)
|
||||
.Include(v => v.Employee)
|
||||
.Include(v => v.Vehicle)
|
||||
.Include(v => v.VehicleFuelType)
|
||||
.Include(v => v.VehicleFuelingCard).FirstOrDefaultAsync(m => m.IdVehicleFueling == id);
|
||||
|
||||
if (VehicleFueling == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
99
EveryThing/Pages/FleetFueling/Edit.cshtml
Normal file
99
EveryThing/Pages/FleetFueling/Edit.cshtml
Normal file
@@ -0,0 +1,99 @@
|
||||
@page
|
||||
@model EveryThing.Pages.FleetFueling.EditModel
|
||||
|
||||
<h4>VehicleFueling</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="VehicleFueling.IdVehicleFueling" />
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdVehicleFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdVehicleFk" class="form-control" asp-items="ViewBag.IdVehicleFk"></select>
|
||||
<span asp-validation-for="VehicleFueling.IdVehicleFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdEmployeeFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdEmployeeFk" class="form-control" asp-items="ViewBag.IdEmployeeFk"></select>
|
||||
<span asp-validation-for="VehicleFueling.IdEmployeeFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.DateOfFueling" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.DateOfFueling" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.DateOfFueling" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdVehicleFuelingCardFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdVehicleFuelingCardFk" class="form-control" asp-items="ViewBag.IdVehicleFuelingCardFk"></select>
|
||||
<span asp-validation-for="VehicleFueling.IdVehicleFuelingCardFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.FuelingCardInvoiceDate" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.FuelingCardInvoiceDate" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.FuelingCardInvoiceDate" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.FuelingCardInvoiceNumber" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.FuelingCardInvoiceNumber" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.FuelingCardInvoiceNumber" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdVehicleFuelTypeFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdVehicleFuelTypeFk" class="form-control" asp-items="ViewBag.IdVehicleFuelTypeFk"></select>
|
||||
<span asp-validation-for="VehicleFueling.IdVehicleFuelTypeFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Quantity" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Quantity" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Quantity" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Mileage" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Mileage" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Mileage" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="VehicleFueling.FullTank" /> @Html.DisplayNameFor(model => model.VehicleFueling.FullTank)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Amount" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Amount" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Amount" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.IdCountryFk" class="control-label"></label>
|
||||
<select asp-for="VehicleFueling.IdCountryFk" class="form-control" asp-items="ViewBag.IdCountryFk"></select>
|
||||
<span asp-validation-for="VehicleFueling.IdCountryFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.City" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.City" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.City" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Reference" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Reference" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Reference" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="VehicleFueling.Note" class="control-label"></label>
|
||||
<input asp-for="VehicleFueling.Note" class="form-control" />
|
||||
<span asp-validation-for="VehicleFueling.Note" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
87
EveryThing/Pages/FleetFueling/Edit.cshtml.cs
Normal file
87
EveryThing/Pages/FleetFueling/Edit.cshtml.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
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.Vehicle;
|
||||
|
||||
namespace EveryThing.Pages.FleetFueling
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public EditModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Models.Vehicle.VehicleFueling VehicleFueling { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
VehicleFueling = await _context.VehicleFuelings
|
||||
.Include(v => v.Country)
|
||||
.Include(v => v.Employee)
|
||||
.Include(v => v.Vehicle)
|
||||
.Include(v => v.VehicleFuelType)
|
||||
.Include(v => v.VehicleFuelingCard).FirstOrDefaultAsync(m => m.IdVehicleFueling == id);
|
||||
|
||||
if (VehicleFueling == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["IdCountryFk"] = new SelectList(_context.CodeTableCountries, "IdCountry", "Title");
|
||||
ViewData["IdEmployeeFk"] = new SelectList(_context.CodeTableEmployees, "IdEmployee", "BankAccount");
|
||||
ViewData["IdVehicleFk"] = new SelectList(_context.Vehicles, "IdVehicle", "RegistrationNumber");
|
||||
ViewData["IdVehicleFuelTypeFk"] = new SelectList(_context.VehicleFuelTypes, "IdVehicleFuelType", "Title");
|
||||
ViewData["IdVehicleFuelingCardFk"] = new SelectList(_context.VehicleFuelingCards, "IdFuelingCard", "CardNumber");
|
||||
return Page();
|
||||
}
|
||||
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(VehicleFueling).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!VehicleFuelingExists(VehicleFueling.IdVehicleFueling))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool VehicleFuelingExists(int id)
|
||||
{
|
||||
return _context.VehicleFuelings.Any(e => e.IdVehicleFueling == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
339
EveryThing/Pages/FleetFueling/Index.cshtml
Normal file
339
EveryThing/Pages/FleetFueling/Index.cshtml
Normal file
@@ -0,0 +1,339 @@
|
||||
@page
|
||||
@model EveryThing.Pages.FleetFueling.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Gorivo";
|
||||
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">Gorivo /</span> Pregled
|
||||
</span>
|
||||
|
||||
<a asp-page="Create" class="btn btn-primary"><span class="fa fas fa-plus"></span> Vnos porabe goriva</a>
|
||||
</h4>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-2">
|
||||
<select type="text" class="form-control selectpicker" data-style="btn-default" placeholder="Jane Doe" asp-items="Html.GetEnumSelectList<Models.CodeTable.CodeTableEmployeeGender>()">
|
||||
<option value="">Vozilo</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select type="text" class="form-control selectpicker" data-style="btn-default" placeholder="Jane Doe" asp-items="Html.GetEnumSelectList<Models.CodeTable.CodeTableEmployeeGender>()">
|
||||
<option value="">Kartica</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select type="text" class="form-control selectpicker" data-style="btn-default" placeholder="Jane Doe" asp-items="Html.GetEnumSelectList<Models.CodeTable.CodeTableEmployeeGender>()">
|
||||
<option value="">Voznik</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-primary"><i class="far fa-sync"></i> Osveži</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-xl-6">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="far fa-road text-danger" style="font-size: 2rem"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Prevoženo [km]</div>
|
||||
<div class="text-large">60.067,00</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-6">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="far fa-gas-pump text-info" style="font-size: 2rem"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Natočeno gorivo [l]</div>
|
||||
<div class="text-large">18.461,00</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-xl-6">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="far fa-leaf text-success" style="font-size: 2rem"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Natočeno AdBlue [l]</div>
|
||||
<div class="text-large">1.572,00</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-6">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="far fa-toolbox text-warning" style="font-size: 2rem"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Gorivo delavnica [l]</div>
|
||||
<div class="text-large">1.484,00</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body p-2">
|
||||
<div style="height: 202px;">
|
||||
<canvas id="statistics-chart-1"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-xl-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="far fa-tachometer-alt text-info" style="font-size: 2rem"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Poraba goriva [l/100km]</div>
|
||||
<div class="text-large">29,87</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-xl-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="far fa-tachometer-alt text-success" style="font-size: 2rem"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Poraba AdBlue [l/100km]</div>
|
||||
<div class="text-large">7,03</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="container-m-nx mt-0 mb-4">
|
||||
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Seznam porabe goriva
|
||||
|
||||
@*<button class="btn btn-sm btn-primary" data-toggle="ajax-modal" data-url="@Url.Page("/Notes/Create", "Modal")">
|
||||
<span class="ion ion-md-add"></span> Vnos porabe goriva
|
||||
</button>*@
|
||||
</h6>
|
||||
<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].DateOfFueling)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].FuelingCardInvoiceDate)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].FuelingCardInvoiceNumber)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].Quantity)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].Mileage)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].FullTank)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].Amount)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].City)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].Reference)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].Note)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].Vehicle)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].Employee)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].Country)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].VehicleFuelingCard)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.VehicleFueling[0].VehicleFuelType)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.VehicleFueling)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOfFueling)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FuelingCardInvoiceDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FuelingCardInvoiceNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Quantity)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Mileage)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FullTank)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Amount)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.City)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Reference)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Note)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Vehicle.RegistrationNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Employee.BankAccount)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Country.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.VehicleFuelingCard.CardNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.VehicleFuelType.Title)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.IdVehicleFueling">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.IdVehicleFueling">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.IdVehicleFueling">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
|
||||
<script src="~/vendor/libs/chartjs/chartjs.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var chart1 = new Chart(document.getElementById('statistics-chart-1').getContext("2d"),
|
||||
{
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: [
|
||||
'2016-10', '2016-11', '2016-12', '2017-01', '2017-02', '2017-03', '2017-04', '2017-05'
|
||||
],
|
||||
datasets: [
|
||||
{
|
||||
label: 'Prevoženo [km]',
|
||||
data: [93, 25, 95, 59, 46, 68, 4, 41],
|
||||
borderWidth: 1,
|
||||
backgroundColor: 'rgba(217,83,79,0)',
|
||||
borderColor: '#d9534f',
|
||||
pointBackgroundColor: '#d9534f'
|
||||
|
||||
}, {
|
||||
label: 'Natočeno gorivo [l]',
|
||||
data: [53, 1, 43, 28, 56, 82, 80, 66],
|
||||
borderWidth: 1,
|
||||
backgroundColor: 'rgba(40,195,215,0)',
|
||||
borderColor: '#28c3d7',
|
||||
pointBackgroundColor: '#28c3d7'
|
||||
}, {
|
||||
label: 'Natočeno AdBlue [l]',
|
||||
data: [83, 1, 20, 28, 70, 82, 40, 66],
|
||||
borderWidth: 1,
|
||||
backgroundColor: 'rgba(2,188,119,0)',
|
||||
borderColor: '#02BC77',
|
||||
pointBackgroundColor: '#02BC77'
|
||||
}, {
|
||||
label: 'Poraba goriva [l/100km]',
|
||||
data: [40, 1, 5, 28, 56, 20, 40, 33],
|
||||
borderWidth: 1,
|
||||
backgroundColor: 'rgba(255,217,80,0)',
|
||||
borderColor: '#FFD950',
|
||||
pointBackgroundColor: '#FFD950'
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [
|
||||
{
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: {
|
||||
fontColor: '#aaa'
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxes: [
|
||||
{
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: {
|
||||
fontColor: '#aaa',
|
||||
stepSize: 10
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
responsive: true,
|
||||
maintainAspectRatio: false
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
34
EveryThing/Pages/FleetFueling/Index.cshtml.cs
Normal file
34
EveryThing/Pages/FleetFueling/Index.cshtml.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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.Vehicle;
|
||||
|
||||
namespace EveryThing.Pages.FleetFueling
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public IndexModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IList<Models.Vehicle.VehicleFueling> VehicleFueling { get;set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
VehicleFueling = await _context.VehicleFuelings
|
||||
.Include(v => v.Country)
|
||||
.Include(v => v.Employee)
|
||||
.Include(v => v.Vehicle)
|
||||
.Include(v => v.VehicleFuelType)
|
||||
.Include(v => v.VehicleFuelingCard).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
64
EveryThing/Pages/FleetIssues/Create.cshtml
Normal file
64
EveryThing/Pages/FleetIssues/Create.cshtml
Normal file
@@ -0,0 +1,64 @@
|
||||
@page "{handler?}"
|
||||
@model EveryThing.Pages.FleetIssues.CreateModel
|
||||
|
||||
<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">Napake /</span> Nova
|
||||
</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">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Issue.IdVehicleIssue" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.Priority" class="control-label"></label>
|
||||
<select asp-for="Issue.Priority" class="form-control"></select>
|
||||
<span asp-validation-for="Issue.Priority" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.Status" class="control-label"></label>
|
||||
<select asp-for="Issue.Status" class="form-control"></select>
|
||||
<span asp-validation-for="Issue.Status" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.IdEmployeeFk" class="control-label"></label>
|
||||
<select asp-for="Issue.IdEmployeeFk" class="form-control" asp-items="ViewBag.IdEmployeeFk"></select>
|
||||
<span asp-validation-for="Issue.IdEmployeeFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.IdVehicleFk" class="control-label"></label>
|
||||
<select asp-for="Issue.IdVehicleFk" class="form-control" asp-items="ViewBag.IdVehicleFk"></select>
|
||||
<span asp-validation-for="Issue.IdVehicleFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.DateReported" class="control-label"></label>
|
||||
<input asp-for="Issue.DateReported" class="form-control" />
|
||||
<span asp-validation-for="Issue.DateReported" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.Description" class="control-label"></label>
|
||||
<input asp-for="Issue.Description" class="form-control" />
|
||||
<span asp-validation-for="Issue.Description" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.Note" class="control-label"></label>
|
||||
<input asp-for="Issue.Note" class="form-control" />
|
||||
<span asp-validation-for="Issue.Note" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
76
EveryThing/Pages/FleetIssues/Create.cshtml.cs
Normal file
76
EveryThing/Pages/FleetIssues/Create.cshtml.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
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 EveryThing.Models.Vehicle;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.FleetIssues
|
||||
{
|
||||
[Authorize]
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public CreateModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public VehicleIssue Issue { get; set; }
|
||||
|
||||
public IActionResult OnGetModal()
|
||||
{
|
||||
ViewData["IdEmployeeFk"] = new SelectList(_context.CodeTableEmployees, "IdEmployee", "BankAccount");
|
||||
ViewData["IdVehicleFk"] = new SelectList(_context.Set<Models.Vehicle.Vehicle>(), "IdVehicle", "RegistrationNumber");
|
||||
|
||||
return Partial("CreateModal");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostModalAsync()
|
||||
{
|
||||
//if (!ModelState.IsValid)
|
||||
//{
|
||||
// return Partial("CreateModal");
|
||||
//}
|
||||
|
||||
var aa = _userManager.GetUserAsync(User);
|
||||
|
||||
_context.VehicleIssues.Add(Issue);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Partial("CreateModal");
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
ViewData["IdEmployeeFk"] = new SelectList(_context.CodeTableEmployees, "IdEmployee", "BankAccount");
|
||||
ViewData["IdVehicleFk"] = new SelectList(_context.Set<Models.Vehicle.Vehicle>(), "IdVehicle", "RegistrationNumber");
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.VehicleIssues.Add(Issue);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
72
EveryThing/Pages/FleetIssues/CreateModal.cshtml
Normal file
72
EveryThing/Pages/FleetIssues/CreateModal.cshtml
Normal file
@@ -0,0 +1,72 @@
|
||||
@using EveryThing.Models
|
||||
@using EveryThing.Models.Vehicle
|
||||
@model EveryThing.Pages.FleetIssues.CreateModel
|
||||
|
||||
<div class="modal fade" id="modals-default">
|
||||
<div class="modal-dialog">
|
||||
<form method="post" class="modal-content" asp-page="/Management/Issues/Create" asp-page-handler="Modal">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<span class="font-weight-light">Napake / </span> Vnos nove napake<br>
|
||||
<small class="text-muted">Vnesite podatke o napaki.</small>
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label asp-for="Issue.IdVehicleFk" class="form-label"></label>
|
||||
<select asp-for="Issue.IdVehicleFk" class="form-control" asp-items="ViewBag.IdVehicleFk"></select>
|
||||
<span asp-validation-for="Issue.IdVehicleFk" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label asp-for="Issue.DateReported" class="form-label"></label>
|
||||
<input asp-for="Issue.DateReported" type="date" class="form-control" />
|
||||
<span asp-validation-for="Issue.DateReported" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label asp-for="Issue.IdEmployeeFk" class="form-label"></label>
|
||||
<select asp-for="Issue.IdEmployeeFk" class="form-control" asp-items="ViewBag.IdEmployeeFk"></select>
|
||||
<span asp-validation-for="Issue.IdEmployeeFk" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label asp-for="Issue.Priority" class="form-label"></label>
|
||||
<select asp-for="Issue.Priority" asp-items="Html.GetEnumSelectList<VehicleIssuePriority>()" class="form-control">
|
||||
<option value="">Izberite prioriteto</option>
|
||||
</select>
|
||||
<span asp-validation-for="Issue.Priority" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label asp-for="Issue.Status" class="form-label"></label>
|
||||
<select asp-for="Issue.Status" asp-items="Html.GetEnumSelectList<VehicleIssueStatus>()" class="form-control">
|
||||
<option value="">Izberite status</option>
|
||||
</select>
|
||||
<span asp-validation-for="Issue.Status" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label asp-for="Issue.Description" class="form-label"></label>
|
||||
<input asp-for="Issue.Description" class="form-control" />
|
||||
<span asp-validation-for="Issue.Description" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col mb-0">
|
||||
<label asp-for="Issue.Note" class="form-label"></label>
|
||||
<input asp-for="Issue.Note" class="form-control" />
|
||||
<span asp-validation-for="Issue.Note" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Prekliči</button>
|
||||
<button type="submit" class="btn btn-primary" data-save="modal">Dodaj</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
65
EveryThing/Pages/FleetIssues/Delete.cshtml
Normal file
65
EveryThing/Pages/FleetIssues/Delete.cshtml
Normal file
@@ -0,0 +1,65 @@
|
||||
@page
|
||||
@model EveryThing.Pages.FleetIssues.DeleteModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Issue</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Priority)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Priority)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Status)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Status)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.DateReported)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.DateReported)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Description)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Description)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Note)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Note)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Employee)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Employee.BankAccount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Vehicle)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Vehicle.RegistrationNumber)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Issue.IdVehicleIssue" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
62
EveryThing/Pages/FleetIssues/Delete.cshtml.cs
Normal file
62
EveryThing/Pages/FleetIssues/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.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Vehicle;
|
||||
|
||||
namespace EveryThing.Pages.FleetIssues
|
||||
{
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public VehicleIssue Issue { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Issue = await _context.VehicleIssues
|
||||
.Include(i => i.Employee)
|
||||
.Include(i => i.Vehicle).FirstOrDefaultAsync(m => m.IdVehicleIssue == id);
|
||||
|
||||
if (Issue == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Issue = await _context.VehicleIssues.FindAsync(id);
|
||||
|
||||
if (Issue != null)
|
||||
{
|
||||
_context.VehicleIssues.Remove(Issue);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
62
EveryThing/Pages/FleetIssues/Details.cshtml
Normal file
62
EveryThing/Pages/FleetIssues/Details.cshtml
Normal file
@@ -0,0 +1,62 @@
|
||||
@page
|
||||
@model EveryThing.Pages.FleetIssues.DetailsModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>Issue</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Priority)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Priority)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Status)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Status)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.DateReported)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.DateReported)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Description)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Description)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Note)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Note)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Employee)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Employee.BankAccount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Issue.Vehicle)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Issue.Vehicle.RegistrationNumber)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Issue.IdVehicleIssue">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
43
EveryThing/Pages/FleetIssues/Details.cshtml.cs
Normal file
43
EveryThing/Pages/FleetIssues/Details.cshtml.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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.Vehicle;
|
||||
|
||||
namespace EveryThing.Pages.FleetIssues
|
||||
{
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DetailsModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public VehicleIssue Issue { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Issue = await _context.VehicleIssues
|
||||
.Include(i => i.Employee)
|
||||
.Include(i => i.Vehicle).FirstOrDefaultAsync(m => m.IdVehicleIssue == id);
|
||||
|
||||
if (Issue == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
66
EveryThing/Pages/FleetIssues/Edit.cshtml
Normal file
66
EveryThing/Pages/FleetIssues/Edit.cshtml
Normal file
@@ -0,0 +1,66 @@
|
||||
@page
|
||||
@model EveryThing.Pages.FleetIssues.EditModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Edit</h1>
|
||||
|
||||
<h4>Issue</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Issue.IdVehicleIssue" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.Priority" class="control-label"></label>
|
||||
<select asp-for="Issue.Priority" class="form-control"></select>
|
||||
<span asp-validation-for="Issue.Priority" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.Status" class="control-label"></label>
|
||||
<select asp-for="Issue.Status" class="form-control"></select>
|
||||
<span asp-validation-for="Issue.Status" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.IdEmployeeFk" class="control-label"></label>
|
||||
<select asp-for="Issue.IdEmployeeFk" class="form-control" asp-items="ViewBag.IdEmployeeFk"></select>
|
||||
<span asp-validation-for="Issue.IdEmployeeFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.IdVehicleFk" class="control-label"></label>
|
||||
<select asp-for="Issue.IdVehicleFk" class="form-control" asp-items="ViewBag.IdVehicleFk"></select>
|
||||
<span asp-validation-for="Issue.IdVehicleFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.DateReported" class="control-label"></label>
|
||||
<input asp-for="Issue.DateReported" class="form-control" />
|
||||
<span asp-validation-for="Issue.DateReported" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.Description" class="control-label"></label>
|
||||
<input asp-for="Issue.Description" class="form-control" />
|
||||
<span asp-validation-for="Issue.Description" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Issue.Note" class="control-label"></label>
|
||||
<input asp-for="Issue.Note" class="form-control" />
|
||||
<span asp-validation-for="Issue.Note" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
80
EveryThing/Pages/FleetIssues/Edit.cshtml.cs
Normal file
80
EveryThing/Pages/FleetIssues/Edit.cshtml.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
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.Vehicle;
|
||||
|
||||
namespace EveryThing.Pages.FleetIssues
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public EditModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public VehicleIssue Issue { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Issue = await _context.VehicleIssues
|
||||
.Include(i => i.Employee)
|
||||
.Include(i => i.Vehicle).FirstOrDefaultAsync(m => m.IdVehicleIssue == id);
|
||||
|
||||
if (Issue == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["IdEmployeeFk"] = new SelectList(_context.CodeTableEmployees, "IdEmployee", "BankAccount");
|
||||
ViewData["IdVehicleFk"] = new SelectList(_context.Set<Models.Vehicle.Vehicle>(), "IdVehicle", "RegistrationNumber");
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(Issue).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!IssueExists(Issue.IdVehicleIssue))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool IssueExists(int id)
|
||||
{
|
||||
return _context.VehicleIssues.Any(e => e.IdVehicleIssue == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
95
EveryThing/Pages/FleetIssues/Index.cshtml
Normal file
95
EveryThing/Pages/FleetIssues/Index.cshtml
Normal file
@@ -0,0 +1,95 @@
|
||||
@page "{handler?}"
|
||||
@model EveryThing.Pages.FleetIssues.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
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">Napake /</span> Pregled
|
||||
</span>
|
||||
|
||||
<a asp-page="Create" class="btn btn-primary"><span class="fa fas fa-plus"></span> Vnos napake</a>
|
||||
</h4>
|
||||
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Seznam napak
|
||||
@*<div class="card-header-elements ml-md-auto">
|
||||
<button class="btn btn-sm btn-primary" data-toggle="ajax-modal" data-url="@Url.Page("/Management/Issues/Create", "Modal")">
|
||||
<span class="ion ion-md-add"></span> Vnos nove napake
|
||||
</button>
|
||||
</div>*@
|
||||
</h6>
|
||||
<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 150px;">
|
||||
@Html.DisplayNameFor(model => model.Issue[0].Priority)
|
||||
</th>
|
||||
<th style="width: 100px;">
|
||||
@Html.DisplayNameFor(model => model.Issue[0].Status)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Issue[0].DateReported)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Issue[0].Description)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Issue[0].Note)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Issue[0].Employee)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Issue[0].Vehicle)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Issue)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Priority)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateReported)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Description)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Note)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Employee.BankAccount)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Vehicle.RegistrationNumber)
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="./Details" asp-route-id="@item.IdVehicleIssue" 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.IdVehicleIssue" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Modal placeholder -->
|
||||
<div id="modal-placeholder"></div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({ container: 'table' });
|
||||
</script>
|
||||
}
|
||||
32
EveryThing/Pages/FleetIssues/Index.cshtml.cs
Normal file
32
EveryThing/Pages/FleetIssues/Index.cshtml.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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.Vehicle;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace EveryThing.Pages.FleetIssues
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public IndexModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IList<VehicleIssue> Issue { get;set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
Issue = await _context.VehicleIssues.Include(i => i.Employee)
|
||||
.Include(i => i.Vehicle).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
627
EveryThing/Pages/Index.cshtml
Normal file
627
EveryThing/Pages/Index.cshtml
Normal file
@@ -0,0 +1,627 @@
|
||||
@page
|
||||
@model IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Pregled";
|
||||
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">EveryThing /</span> Pregled
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="lnr lnr-exit-up display-4 text-success"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Prodaja zadnjih 30 dni</div>
|
||||
<div id="divLblSales" class="text-large">2362</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="lnr lnr-enter-down display-4 text-info"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Stroški zadnjih 30 dni</div>
|
||||
<div id="divLblExpenses" class="text-large">687,123</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-2">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="lnr lnr-highlight display-4 text-info"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">RVC zadnjih 30 dni</div>
|
||||
<div id="divLblDifferenceInPrice" class="text-large">687,123</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-2">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="lnr lnr-screen display-4 text-danger"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Aktivni projekti</div>
|
||||
<div id="divLblActiveProjects" class="text-large">985</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-2">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="lnr lnr-screen display-4 text-danger"></div>
|
||||
<div class="ml-3">
|
||||
<div class="text-muted small">Leto</div>
|
||||
<select asp-for="Year" class="form-control sel-year" asp-items="ViewBag.Years"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-xl-6">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<canvas id="chartDiferenceInPriceMonth" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-6">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<canvas id="chartDiferenceInPriceYear" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-xl-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<canvas id="chartDiferenceInPricePartnersYear" height="500"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-xl-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<canvas id="chartDiferenceInPriceProjectsYear" height="500"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@*<hr class="container-m-nx mt-0 mb-4">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card mb-4">
|
||||
<h6 class="card-header">Prihajajoči dogodki</h6>
|
||||
<div style="height: 500px" id="upcomming-events">
|
||||
<div class="card-body">
|
||||
<div class="media">
|
||||
<div class="ui-icon ui-activity-icon far fa-sticky-note text-secondary"></div>
|
||||
<div class="media-body ml-3">
|
||||
Zapiski <a href="#">Preveri dobavo materiala</a>
|
||||
<div class="text-muted small"><b>Danes</b> - 3.3.2020 14:30 (sreda) - še 15 minut</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class=" mt-0 mb-2 mt-2">
|
||||
<div class="media">
|
||||
<div class="ui-icon ui-activity-icon fas fa-exclamation text-secondary"></div>
|
||||
<div class="media-body ml-3">
|
||||
Napaka <a href="#">MAN (SG-AB-123)</a> (Napaka na motorju - Prižiga se lučka za olje)
|
||||
<div class="text-muted small">20.2.2020 (petek) - zamujeno 2 uri</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class=" mt-0 mb-2 mt-2">
|
||||
<div class="media">
|
||||
<div class="ui-icon ui-activity-icon fas fa-truck text-secondary"></div>
|
||||
<div class="media-body ml-3">
|
||||
Tehnični pregled <a href="#">MAN (SG-CD-234)</a>
|
||||
<div class="text-muted small">8.5.2020 (ponedeljek) - še 30 dni</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class=" mt-0 mb-2 mt-2">
|
||||
<div class="media">
|
||||
<div class="ui-icon ui-activity-icon fas fa-users text-secondary"></div>
|
||||
<div class="media-body ml-3">
|
||||
Zdravniški pregled <a href="#">Janez Novak</a>
|
||||
<div class="text-muted small">1.4.2020 (torek) - še 10 dni</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class=" mt-0 mb-2 mt-2">
|
||||
<div class="media">
|
||||
<div class="ui-icon ui-activity-icon far fa-cogs text-secondary"></div>
|
||||
<div class="media-body ml-3">
|
||||
Servis <a href="#">Prikolica Krone (SG-GH-321)</a> (Menjava gum)
|
||||
<div class="text-muted small">8.4.2020 (torek) - še 10 dni</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class=" mt-0 mb-2 mt-2">
|
||||
<div class="media">
|
||||
<div class="ui-icon ui-activity-icon fas fa-tasks text-secondary"></div>
|
||||
<div class="media-body ml-3">
|
||||
Pregled <a href="#">MAN (SG-EF-789)</a> (Mesečna kontrola nivoja olja)
|
||||
<div class="text-muted small">10.4.2020 (sreda) - še 12 dni</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card mb-4">
|
||||
<h6 class="card-header">Weather</h6>
|
||||
<div class="row no-gutters row-bordered text-center">
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="py-2">Sunday</div>
|
||||
<hr class="m-0">
|
||||
<div class="py-4">
|
||||
<div class="ion ion-md-sunny display-3 text-warning mb-3"></div>
|
||||
<div class="text-xlarge mb-3">+20°</div>
|
||||
<div class="text-muted">Sunny day</div>
|
||||
</div>
|
||||
<hr class="m-0">
|
||||
<div class="text-muted py-2">
|
||||
May 21
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="py-2">Monday</div>
|
||||
<hr class="m-0">
|
||||
<div class="py-4">
|
||||
<div class="ion ion-md-rainy display-3 text-info mb-3"></div>
|
||||
<div class="text-xlarge mb-3">+15°</div>
|
||||
<div class="text-muted">Rainy day</div>
|
||||
</div>
|
||||
<hr class="m-0">
|
||||
<div class="text-muted py-2">
|
||||
May 22
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="py-2">Tuesday</div>
|
||||
<hr class="m-0">
|
||||
<div class="py-4">
|
||||
<div class="ion ion-md-partly-sunny display-3 text-secondary mb-3"></div>
|
||||
<div class="text-xlarge mb-3">+18°</div>
|
||||
<div class="text-muted">Cloudy day</div>
|
||||
</div>
|
||||
<hr class="m-0">
|
||||
<div class="text-muted py-2">
|
||||
May 23
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="py-2">Wednesday</div>
|
||||
<hr class="m-0">
|
||||
<div class="py-4">
|
||||
<div class="ion ion-md-rainy display-3 text-info mb-3"></div>
|
||||
<div class="text-xlarge mb-3">+17°</div>
|
||||
<div class="text-muted">Rainy day</div>
|
||||
</div>
|
||||
<hr class="m-0">
|
||||
<div class="text-muted py-2">
|
||||
May 24
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card mb-4">
|
||||
<h6 class="card-header">Podjetje</h6>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item py-3">
|
||||
<div class="media">
|
||||
<div class="far fa-building ui-w-30 text-center text-lighter mt-1"></div>
|
||||
<div class="media-body ml-2">
|
||||
Moje podjetje d.o.o.
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item py-3">
|
||||
<div class="media">
|
||||
<div class="far fa-map-marker-alt ui-w-30 text-center text-lighter mt-1"></div>
|
||||
<div class="media-body ml-2">
|
||||
Ulica 110, 1234 Pošta v Sloveniji
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item py-3">
|
||||
<div class="media">
|
||||
<div class="far fa-info-circle ui-w-30 text-center text-lighter mt-1"></div>
|
||||
<div class="media-body ml-2">
|
||||
Davčna številka: SI321654987
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
<script src="~/vendor/libs/chartjs/chartjs.js" asp-append-version="true"></script>
|
||||
<script src="~/vendor/libs/chartjs/chartjs-plugin-colorschemes.min.js" asp-append-version="true"></script>
|
||||
<script>
|
||||
let graphDifferenceInPriceMonth;
|
||||
let graphDifferenceInPriceYear;
|
||||
let graphDifferenceInPricePartnersYear;
|
||||
let graphDifferenceInPriceProjectsYear;
|
||||
//new PerfectScrollbar(document.getElementById('upcomming-events'));
|
||||
|
||||
$(document).ready(function () {
|
||||
refreshData();
|
||||
$('.sel-year').on('change', function() {
|
||||
refreshData();
|
||||
});
|
||||
});
|
||||
|
||||
function refreshData() {
|
||||
let year = parseInt($('.sel-year').val());
|
||||
|
||||
$.blockUI();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "Index/?handler=Data",
|
||||
data: { year },
|
||||
success: function (data) {
|
||||
$.unblockUI();
|
||||
if (data.successful) {
|
||||
setData(data.data);
|
||||
} else {
|
||||
Swal.fire('Napaka pri osveževanju grafov!',
|
||||
data.error,
|
||||
'warning');
|
||||
}
|
||||
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setData(data) {
|
||||
//Graf Mesec
|
||||
if (graphDifferenceInPriceMonth != null) {
|
||||
graphDifferenceInPriceMonth.destroy();
|
||||
}
|
||||
|
||||
graphDifferenceInPriceMonth = new Chart($('#chartDiferenceInPriceMonth'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: data.month.xAxis,
|
||||
datasets: [
|
||||
{
|
||||
data: data.month.diferenceInPrice,
|
||||
label: "Rvc",
|
||||
type: "line",
|
||||
fill: false,
|
||||
order: 1
|
||||
},
|
||||
{
|
||||
data: data.month.expenses,
|
||||
label: "Stroški",
|
||||
type: "bar",
|
||||
order: 2
|
||||
}, {
|
||||
data: data.month.sales,
|
||||
label: "Prodaja",
|
||||
type: "bar",
|
||||
order: 3
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
legend: {
|
||||
text: 'test123',
|
||||
display: true,
|
||||
position: 'bottom'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Odprema pozicij delov projektov po dnevih za preteklih 30 dni'
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
// min: yMinVal,
|
||||
suggestedMin: 0,
|
||||
},
|
||||
|
||||
}],
|
||||
xAxis: [{
|
||||
type: 'time',
|
||||
}]
|
||||
},
|
||||
plugins: {
|
||||
|
||||
colorschemes: {
|
||||
|
||||
scheme: 'brewer.PastelOne3'
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
title: function(tooltipItems, data) {
|
||||
return data.datasets[tooltipItems[0].datasetIndex].data[tooltipItems[0].index].x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Graf Leto
|
||||
if (graphDifferenceInPriceYear!= null) {
|
||||
graphDifferenceInPriceYear.destroy();
|
||||
}
|
||||
|
||||
graphDifferenceInPriceYear = new Chart($('#chartDiferenceInPriceYear'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: data.year.xAxis,
|
||||
datasets: [
|
||||
{
|
||||
data: data.year.diferenceInPrice,
|
||||
label: "Rvc",
|
||||
type: "line",
|
||||
fill: false,
|
||||
order: 1
|
||||
},
|
||||
{
|
||||
data: data.year.expenses,
|
||||
label: "Stroški",
|
||||
type: "bar",
|
||||
order: 2
|
||||
}, {
|
||||
data: data.year.sales,
|
||||
label: "Prodaja",
|
||||
type: "bar",
|
||||
order: 3
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
legend: {
|
||||
text: 'test123',
|
||||
display: true,
|
||||
position: 'bottom'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Odprema pozicij delov projektov po dnevih za izbrano leto'
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
// min: yMinVal,
|
||||
suggestedMin: 0,
|
||||
},
|
||||
|
||||
}],
|
||||
xAxis: [{
|
||||
type: 'time',
|
||||
}]
|
||||
},
|
||||
plugins: {
|
||||
|
||||
colorschemes: {
|
||||
|
||||
scheme: 'brewer.PastelOne3'
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
title: function (tooltipItems, data) {
|
||||
return data.datasets[tooltipItems[0].datasetIndex].data[tooltipItems[0].index].x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Napisi - Labels
|
||||
$('#divLblActiveProjects').text(data.labels.activeProjects);
|
||||
$('#divLblDifferenceInPrice').text(data.labels.diferenceInPrice + ' €');
|
||||
$('#divLblExpenses').text(data.labels.expenses + ' €');
|
||||
$('#divLblSales').text(data.labels.sales + ' €');
|
||||
|
||||
//Graf partnerji leto
|
||||
if (graphDifferenceInPricePartnersYear != null) {
|
||||
graphDifferenceInPricePartnersYear.destroy();
|
||||
}
|
||||
|
||||
graphDifferenceInPricePartnersYear = new Chart($('#chartDiferenceInPricePartnersYear'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: data.partnersYear.xAxis,
|
||||
datasets: [
|
||||
{
|
||||
data: data.partnersYear.diferenceInPrice,
|
||||
label: "Rvc",
|
||||
type: "line",
|
||||
fill: false,
|
||||
order: 1
|
||||
},
|
||||
{
|
||||
data: data.partnersYear.expenses,
|
||||
label: "Stroški",
|
||||
type: "bar",
|
||||
order: 2
|
||||
}, {
|
||||
data: data.partnersYear.sales,
|
||||
label: "Prodaja",
|
||||
type: "bar",
|
||||
order: 3
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
legend: {
|
||||
text: 'test123',
|
||||
display: true,
|
||||
position: 'bottom'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Odprema pozicij delov projektov po partnerjih za izbrano leto'
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
// min: yMinVal,
|
||||
suggestedMin: 0,
|
||||
},
|
||||
|
||||
}],
|
||||
xAxis: [{
|
||||
type: 'time',
|
||||
}]
|
||||
},
|
||||
plugins: {
|
||||
|
||||
colorschemes: {
|
||||
|
||||
scheme: 'brewer.PastelOne3'
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
title: function (tooltipItems, data) {
|
||||
return data.datasets[tooltipItems[0].datasetIndex].data[tooltipItems[0].index].x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Graf projekti leto
|
||||
if (graphDifferenceInPriceProjectsYear != null) {
|
||||
graphDifferenceInPriceProjectsYear.destroy();
|
||||
}
|
||||
|
||||
graphDifferenceInPriceProjectsYear = new Chart($('#chartDiferenceInPriceProjectsYear'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: data.projectsYear.xAxis,
|
||||
datasets: [
|
||||
{
|
||||
data: data.projectsYear.diferenceInPrice,
|
||||
label: "Rvc",
|
||||
type: "line",
|
||||
fill: false,
|
||||
order: 1
|
||||
},
|
||||
{
|
||||
data: data.projectsYear.expenses,
|
||||
label: "Stroški",
|
||||
type: "bar",
|
||||
order: 2
|
||||
}, {
|
||||
data: data.projectsYear.sales,
|
||||
label: "Prodaja",
|
||||
type: "bar",
|
||||
order: 3
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
legend: {
|
||||
text: 'test123',
|
||||
display: true,
|
||||
position: 'bottom'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Odprema pozicij delov projektov po projektih za izbrano leto'
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
// min: yMinVal,
|
||||
suggestedMin: 0,
|
||||
},
|
||||
|
||||
}],
|
||||
xAxis: [{
|
||||
type: 'time',
|
||||
}]
|
||||
},
|
||||
plugins: {
|
||||
|
||||
colorschemes: {
|
||||
|
||||
scheme: 'brewer.PastelOne3'
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
title: function (tooltipItems, data) {
|
||||
return data.datasets[tooltipItems[0].datasetIndex].data[tooltipItems[0].index].x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user