58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
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 FakturyWeb.Data;
|
|
using RazorPagesMovie.Models;
|
|
using FakturyWeb.Business;
|
|
|
|
namespace FakturyWeb.Pages.Faktury
|
|
{
|
|
public class CreateModel : PageModel
|
|
{
|
|
private readonly FakturyWeb.Data.FakturyWebContext _context;
|
|
|
|
public CreateModel(FakturyWeb.Data.FakturyWebContext context)
|
|
{
|
|
_context = context;
|
|
FAKTURA = new FAKTURA();
|
|
FAKTURA.Init(_context);
|
|
}
|
|
|
|
public IActionResult OnGet()
|
|
{
|
|
ViewData["Zakaznici"] = new SelectList(_context.ZAKAZNIK, "ID", "PRAJM");
|
|
|
|
ViewData["FormyUhrady"] = new SelectList(Ciselniky.CreateFormaUhradyDictionary(), "Key", "Value");
|
|
|
|
return Page();
|
|
}
|
|
|
|
[BindProperty]
|
|
public FAKTURA FAKTURA { get; set; }
|
|
|
|
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
|
|
public async Task<IActionResult> OnPostAsync()
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return Page();
|
|
}
|
|
|
|
_context.FAKTURA.Add(FAKTURA);
|
|
await _context.SaveChangesAsync();
|
|
|
|
return RedirectToPage("./Index");
|
|
}
|
|
|
|
public Task<ContentResult> OnGetZakaznik(int zakaznikID)
|
|
{
|
|
// vrat zakaznika
|
|
//viz: https://stackoverflow.com/questions/68854396/how-do-i-load-form-fields-based-on-a-value-changed-in-a-dropdownlist-in-my-asp-n
|
|
}
|
|
}
|
|
}
|