Prvi commit
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user