This commit is contained in:
David Štaleker
2025-07-18 05:33:16 +02:00
parent 401a367e5d
commit db0cc8d3de
14776 changed files with 9251484 additions and 0 deletions

View 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");}
}

View 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");
}
}
}

View 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>

View 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");
}
}
}

View 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>

View 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();
}
}
}

View 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");}
}

View 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);
}
}
}

View 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>

View 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();
//}
}
}

View 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>