prvi
This commit is contained in:
85
EveryThing/Pages/Notes/Create.cshtml
Normal file
85
EveryThing/Pages/Notes/Create.cshtml
Normal file
@@ -0,0 +1,85 @@
|
||||
@page
|
||||
@using EveryThing.Models
|
||||
@model EveryThing.Pages.Notes.CreateModel
|
||||
|
||||
|
||||
@section Styles {
|
||||
<link rel="stylesheet" href="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.css">
|
||||
}
|
||||
|
||||
<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">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.IdCompanyFk" class="control-label"></label>
|
||||
<select asp-for="Note.IdCompanyFk" class="form-control" asp-items="ViewBag.IdCompanyFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.Status" class="control-label"></label>
|
||||
<select asp-for="Note.Status" class="form-control" asp-items="Html.GetEnumSelectList<GeneralNoteStatus>()"></select>
|
||||
<span asp-validation-for="Note.Status" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
@foreach (var tempEnum in Enum.GetValues(typeof(GeneralNoteStatus)))
|
||||
{
|
||||
<label class="custom-control custom-radio">
|
||||
@Html.RadioButtonFor(m => m.Note.Status, tempEnum.ToString(), new { @class = "custom-control-input" }) <span class="custom-control-label">@tempEnum.ToString()</span>
|
||||
</label>
|
||||
}
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.IdEmployeeFk" class="control-label"></label>
|
||||
<select asp-for="Note.IdEmployeeFk" class="form-control" asp-items="ViewBag.IdEmployeeFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.IdVehicleFk" class="control-label"></label>
|
||||
<select asp-for="Note.IdVehicleFk" class="form-control" asp-items="ViewBag.IdVehicleFk"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.DateSubmitted" class="control-label"></label>
|
||||
<input asp-for="Note.DateSubmitted" class="form-control" />
|
||||
<span asp-validation-for="Note.DateSubmitted" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.DateReminder" class="control-label"></label>
|
||||
<input asp-for="Note.DateReminder" class="form-control" />
|
||||
<span asp-validation-for="Note.DateReminder" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<input type="text" id="b-m-dtp-datetime" class="form-control" placeholder="DateTime">
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.Description" class="control-label"></label>
|
||||
<input asp-for="Note.Description" class="form-control" />
|
||||
<span asp-validation-for="Note.Description" 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");}
|
||||
|
||||
<script src="~/vendor/libs/moment/moment.js"></script>
|
||||
<script src="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.js"></script>
|
||||
<script src="~/js/forms.js" asp-append-version="true"></script>
|
||||
}
|
||||
72
EveryThing/Pages/Notes/Create.cshtml.cs
Normal file
72
EveryThing/Pages/Notes/Create.cshtml.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Notes
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly EveryThing.Data.ApplicationDbContext _context;
|
||||
|
||||
public CreateModel(EveryThing.Data.ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Ceo");
|
||||
ViewData["IdEmployeeFk"] = new SelectList(_context.CodeTableEmployees, "IdEmployee", "BankAccount");
|
||||
ViewData["IdVehicleFk"] = new SelectList(_context.Set<Models.Vehicle.Vehicle>(), "IdVehicle", "RegistrationNumber");
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public IActionResult OnGetModal()
|
||||
{
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Ceo");
|
||||
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");
|
||||
}
|
||||
|
||||
_context.GeneralNotes.Add(Note);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Partial("CreateModal");
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public GeneralNote Note { 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.GeneralNotes.Add(Note);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
78
EveryThing/Pages/Notes/CreateModal.cshtml
Normal file
78
EveryThing/Pages/Notes/CreateModal.cshtml
Normal file
@@ -0,0 +1,78 @@
|
||||
@using EveryThing.Models
|
||||
|
||||
@model EveryThing.Pages.Notes.CreateModel
|
||||
|
||||
@section Styles {
|
||||
<link rel="stylesheet" href="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.css">
|
||||
}
|
||||
|
||||
<div class="modal fade" id="modals-default">
|
||||
<div class="modal-dialog">
|
||||
<form method="post" class="modal-content" asp-page="/Notes/Create" asp-page-handler="Modal">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<span class="font-weight-light">Zapiski / </span> Vnos novega zapiska<br>
|
||||
<small class="text-muted">Vnesite podatke zapiska.</small>
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.Description" class="form-label"></label>
|
||||
<textarea asp-for="Note.Description" class="form-control" style="resize: none"></textarea>
|
||||
<span asp-validation-for="Note.Description" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.IdEmployeeFk" class="form-label"></label>
|
||||
<select asp-for="Note.IdEmployeeFk" class="form-control" asp-items="ViewBag.IdEmployeeFk"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.IdVehicleFk" class="form-label"></label>
|
||||
<select asp-for="Note.IdVehicleFk" class="form-control" asp-items="ViewBag.IdVehicleFk"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.Status" class="form-label"></label><br />
|
||||
@foreach (var tempEnum in Enum.GetValues(typeof(GeneralNoteStatus)))
|
||||
{
|
||||
<label class="custom-control custom-radio">
|
||||
@Html.RadioButtonFor(m => m.Note.Status, tempEnum.ToString(), new { @class = "custom-control-input" }) <span class="custom-control-label">@tempEnum.ToString()</span>
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.DateReminder" class="form-label"></label>
|
||||
<input asp-for="Note.DateReminder" type="text" class="dtp-datetime form-control" placeholder="DateTime">
|
||||
<span asp-validation-for="Note.DateReminder" class="text-danger"></span>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
@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 src="~/js/forms.js" asp-append-version="true"></script>
|
||||
}
|
||||
58
EveryThing/Pages/Notes/Delete.cshtml
Normal file
58
EveryThing/Pages/Notes/Delete.cshtml
Normal file
@@ -0,0 +1,58 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Notes.DeleteModel
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Note</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Status)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Status)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.DateSubmitted)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.DateSubmitted)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.DateReminder)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.DateReminder)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Description)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Description)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Employee)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Employee.BankAccount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Vehicle)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Vehicle.RegistrationNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Company.Ceo)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Note.IdNote" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
62
EveryThing/Pages/Notes/Delete.cshtml.cs
Normal file
62
EveryThing/Pages/Notes/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;
|
||||
|
||||
namespace EveryThing.Pages.Notes
|
||||
{
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly EveryThing.Data.ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(EveryThing.Data.ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public GeneralNote Note { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Note = await _context.GeneralNotes
|
||||
.Include(n => n.Company)
|
||||
.Include(n => n.Employee)
|
||||
.Include(n => n.Vehicle).FirstOrDefaultAsync(m => m.IdNote == id);
|
||||
|
||||
if (Note == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Note = await _context.GeneralNotes.FindAsync(id);
|
||||
|
||||
if (Note != null)
|
||||
{
|
||||
_context.GeneralNotes.Remove(Note);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
55
EveryThing/Pages/Notes/Details.cshtml
Normal file
55
EveryThing/Pages/Notes/Details.cshtml
Normal file
@@ -0,0 +1,55 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Notes.DetailsModel
|
||||
|
||||
<div>
|
||||
<h4>Note</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Status)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Status)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.DateSubmitted)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.DateSubmitted)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.DateReminder)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.DateReminder)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Description)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Description)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Employee)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Employee.BankAccount)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Vehicle)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Vehicle.RegistrationNumber)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Note.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Note.Company.Ceo)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Note.IdNote">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
44
EveryThing/Pages/Notes/Details.cshtml.cs
Normal file
44
EveryThing/Pages/Notes/Details.cshtml.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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.Notes
|
||||
{
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DetailsModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public GeneralNote Note { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Note = await _context.GeneralNotes
|
||||
.Include(n => n.Company)
|
||||
.Include(n => n.Employee)
|
||||
.Include(n => n.Vehicle).FirstOrDefaultAsync(m => m.IdNote == id);
|
||||
|
||||
if (Note == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
59
EveryThing/Pages/Notes/Edit.cshtml
Normal file
59
EveryThing/Pages/Notes/Edit.cshtml
Normal file
@@ -0,0 +1,59 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Notes.EditModel
|
||||
|
||||
<h4>Note</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="Note.IdNote" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.IdCompanyFk" class="control-label"></label>
|
||||
<select asp-for="Note.IdCompanyFk" class="form-control" asp-items="ViewBag.IdCompanyFk"></select>
|
||||
<span asp-validation-for="Note.IdCompanyFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.Status" class="control-label"></label>
|
||||
<select asp-for="Note.Status" class="form-control"></select>
|
||||
<span asp-validation-for="Note.Status" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.IdEmployeeFk" class="control-label"></label>
|
||||
<select asp-for="Note.IdEmployeeFk" class="form-control" asp-items="ViewBag.IdEmployeeFk"></select>
|
||||
<span asp-validation-for="Note.IdEmployeeFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.IdVehicleFk" class="control-label"></label>
|
||||
<select asp-for="Note.IdVehicleFk" class="form-control" asp-items="ViewBag.IdVehicleFk"></select>
|
||||
<span asp-validation-for="Note.IdVehicleFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.DateSubmitted" class="control-label"></label>
|
||||
<input asp-for="Note.DateSubmitted" class="form-control" />
|
||||
<span asp-validation-for="Note.DateSubmitted" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.DateReminder" class="control-label"></label>
|
||||
<input asp-for="Note.DateReminder" class="form-control" />
|
||||
<span asp-validation-for="Note.DateReminder" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Note.Description" class="control-label"></label>
|
||||
<input asp-for="Note.Description" class="form-control" />
|
||||
<span asp-validation-for="Note.Description" 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");}
|
||||
}
|
||||
84
EveryThing/Pages/Notes/Edit.cshtml.cs
Normal file
84
EveryThing/Pages/Notes/Edit.cshtml.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
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.Notes
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public EditModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public GeneralNote Note { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Note = await _context.GeneralNotes
|
||||
.Include(n => n.Company)
|
||||
.Include(n => n.Employee)
|
||||
.Include(n => n.Vehicle).FirstOrDefaultAsync(m => m.IdNote == id);
|
||||
|
||||
if (Note == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["IdCompanyFk"] = new SelectList(_context.CodeTableCompanies, "IdCompany", "Ceo");
|
||||
ViewData["IdEmployeeFk"] = new SelectList(_context.CodeTableEmployees, "IdEmployee", "BankAccount");
|
||||
ViewData["IdVehicleFk"] = new SelectList(_context.Set<Vehicle>(), "IdVehicle", "RegistrationNumber");
|
||||
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(Note).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!NoteExists(Note.IdNote))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool NoteExists(int id)
|
||||
{
|
||||
return _context.GeneralNotes.Any(e => e.IdNote == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
98
EveryThing/Pages/Notes/Index.cshtml
Normal file
98
EveryThing/Pages/Notes/Index.cshtml
Normal file
@@ -0,0 +1,98 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Notes.IndexModel
|
||||
|
||||
@{
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
<link rel="stylesheet" href="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.css">
|
||||
}
|
||||
|
||||
<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">Zapiski /</span> Pregled
|
||||
</span>
|
||||
|
||||
<a asp-page="Create" class="btn btn-primary"><span class="fa fas fa-plus"></span> Vnos zapiska</a>
|
||||
</h4>
|
||||
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Seznam zapiskov
|
||||
@*<div class="card-header-elements ml-md-auto">
|
||||
<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 novega zapiska
|
||||
</button>
|
||||
</div>*@
|
||||
</h6>
|
||||
<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Status)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].DateSubmitted)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].DateReminder)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Description)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Employee)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Vehicle)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Company)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Note)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateSubmitted)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateReminder)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Description)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Employee.BankAccount)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Vehicle.RegistrationNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Company.Ceo)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.IdNote">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.IdNote">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.IdNote">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Modal placeholder -->
|
||||
<div id="modal-placeholder"></div>
|
||||
|
||||
@section Scripts {
|
||||
<script src="~/vendor/libs/moment/moment.js"></script>
|
||||
<script src="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.js"></script>
|
||||
}
|
||||
44
EveryThing/Pages/Notes/Index.cshtml.cs
Normal file
44
EveryThing/Pages/Notes/Index.cshtml.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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;
|
||||
|
||||
namespace EveryThing.Pages.Notes
|
||||
{
|
||||
[Authorize]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public IndexModel(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IList<GeneralNote> Note { get;set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
Note = await _context.GeneralNotes
|
||||
.Include(n => n.Company)
|
||||
.Include(n => n.Employee)
|
||||
.Include(n => n.Vehicle).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetModalAsync()
|
||||
{
|
||||
Note = await _context.GeneralNotes
|
||||
.Include(n => n.Company)
|
||||
.Include(n => n.Employee)
|
||||
.Include(n => n.Vehicle).ToListAsync();
|
||||
|
||||
return Partial("IndexModal", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
78
EveryThing/Pages/Notes/IndexModal.cshtml
Normal file
78
EveryThing/Pages/Notes/IndexModal.cshtml
Normal file
@@ -0,0 +1,78 @@
|
||||
@model EveryThing.Pages.Notes.IndexModel
|
||||
|
||||
@section Styles {
|
||||
<link rel="stylesheet" href="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.css">
|
||||
}
|
||||
|
||||
<div class="card">
|
||||
<table class="table card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Status)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].DateSubmitted)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].DateReminder)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Description)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Employee)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Vehicle)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Note[0].Company)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Note)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateSubmitted)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateReminder)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Description)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Employee.BankAccount)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Vehicle.RegistrationNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Company.Ceo)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.IdNote">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.IdNote">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.IdNote">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Modal placeholder -->
|
||||
<div id="modal-placeholder"></div>
|
||||
|
||||
@section Scripts {
|
||||
<script src="~/vendor/libs/moment/moment.js"></script>
|
||||
<script src="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.js"></script>
|
||||
<script src="~/js/forms.js" asp-append-version="true"></script>
|
||||
}
|
||||
Reference in New Issue
Block a user