2023-03-19 17:57:55 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2026-07-06 00:47:35 +01:00
|
|
|
using Microsoft.Extensions.Localization;
|
2018-05-04 13:56:22 +02:00
|
|
|
using Yavsc.Models;
|
|
|
|
|
using Yavsc.Models.Workflow;
|
2025-07-15 19:43:41 +01:00
|
|
|
using Yavsc.Server.Helpers;
|
2026-07-06 00:47:35 +01:00
|
|
|
using Yavsc.Services;
|
2018-05-04 13:56:22 +02:00
|
|
|
|
|
|
|
|
namespace Yavsc.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class CommandFormsController : Controller
|
|
|
|
|
{
|
2020-10-09 19:35:39 +01:00
|
|
|
private readonly ApplicationDbContext _context;
|
2026-07-06 00:47:35 +01:00
|
|
|
private readonly IStringLocalizer<CommandFormsController> _localizer;
|
2018-05-04 13:56:22 +02:00
|
|
|
|
2026-07-06 00:47:35 +01:00
|
|
|
public CommandFormsController(ApplicationDbContext context,
|
|
|
|
|
IStringLocalizer<CommandFormsController> localizer)
|
2018-05-04 13:56:22 +02:00
|
|
|
{
|
2019-05-24 20:17:24 +01:00
|
|
|
_context = context;
|
2026-07-06 00:47:35 +01:00
|
|
|
_localizer = localizer;
|
2018-05-04 13:56:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GET: CommandForms
|
|
|
|
|
public async Task<IActionResult> Index()
|
|
|
|
|
{
|
|
|
|
|
var applicationDbContext = _context.CommandForm.Include(c => c.Context);
|
|
|
|
|
return View(await applicationDbContext.ToListAsync());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GET: CommandForms/Details/5
|
|
|
|
|
public async Task<IActionResult> Details(long? id)
|
|
|
|
|
{
|
|
|
|
|
if (id == null)
|
|
|
|
|
{
|
2023-03-19 17:57:55 +00:00
|
|
|
return NotFound();
|
2018-05-04 13:56:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
|
|
|
|
if (commandForm == null)
|
|
|
|
|
{
|
2023-03-19 17:57:55 +00:00
|
|
|
return NotFound();
|
2018-05-04 13:56:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return View(commandForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GET: CommandForms/Create
|
|
|
|
|
public IActionResult Create()
|
|
|
|
|
{
|
|
|
|
|
SetViewBag();
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2026-07-06 00:47:35 +01:00
|
|
|
|
2019-05-24 20:17:24 +01:00
|
|
|
private void SetViewBag(CommandForm commandForm = null)
|
|
|
|
|
{
|
2018-05-04 13:56:22 +02:00
|
|
|
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode);
|
2026-07-06 00:47:35 +01:00
|
|
|
ViewBag.ActionName = BillingService.Billing.Keys
|
|
|
|
|
.Select((string b) => new SelectListItem { Value = b, Text = _localizer[b] }).ToList();
|
2018-05-04 13:56:22 +02:00
|
|
|
}
|
2026-07-06 00:47:35 +01:00
|
|
|
|
2018-05-04 13:56:22 +02:00
|
|
|
// POST: CommandForms/Create
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ValidateAntiForgeryToken]
|
|
|
|
|
public async Task<IActionResult> Create(CommandForm commandForm)
|
|
|
|
|
{
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
_context.CommandForm.Add(commandForm);
|
|
|
|
|
await _context.SaveChangesAsync(User.GetUserId());
|
|
|
|
|
return RedirectToAction("Index");
|
|
|
|
|
}
|
|
|
|
|
SetViewBag(commandForm);
|
|
|
|
|
return View(commandForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GET: CommandForms/Edit/5
|
|
|
|
|
public async Task<IActionResult> Edit(long? id)
|
|
|
|
|
{
|
|
|
|
|
if (id == null)
|
|
|
|
|
{
|
2023-03-19 17:57:55 +00:00
|
|
|
return NotFound();
|
2018-05-04 13:56:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
|
|
|
|
if (commandForm == null)
|
|
|
|
|
{
|
2023-03-19 17:57:55 +00:00
|
|
|
return NotFound();
|
2018-05-04 13:56:22 +02:00
|
|
|
}
|
|
|
|
|
SetViewBag(commandForm);
|
|
|
|
|
return View(commandForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// POST: CommandForms/Edit/5
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ValidateAntiForgeryToken]
|
|
|
|
|
public async Task<IActionResult> Edit(CommandForm commandForm)
|
|
|
|
|
{
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
_context.Update(commandForm);
|
|
|
|
|
await _context.SaveChangesAsync(User.GetUserId());
|
|
|
|
|
return RedirectToAction("Index");
|
|
|
|
|
}
|
|
|
|
|
SetViewBag(commandForm);
|
|
|
|
|
return View(commandForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GET: CommandForms/Delete/5
|
|
|
|
|
[ActionName("Delete")]
|
|
|
|
|
public async Task<IActionResult> Delete(long? id)
|
|
|
|
|
{
|
|
|
|
|
if (id == null)
|
|
|
|
|
{
|
2023-03-19 17:57:55 +00:00
|
|
|
return NotFound();
|
2018-05-04 13:56:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
|
|
|
|
if (commandForm == null)
|
|
|
|
|
{
|
2023-03-19 17:57:55 +00:00
|
|
|
return NotFound();
|
2018-05-04 13:56:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return View(commandForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// POST: CommandForms/Delete/5
|
|
|
|
|
[HttpPost, ActionName("Delete")]
|
|
|
|
|
[ValidateAntiForgeryToken]
|
|
|
|
|
public async Task<IActionResult> DeleteConfirmed(long id)
|
|
|
|
|
{
|
|
|
|
|
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
|
|
|
|
_context.CommandForm.Remove(commandForm);
|
|
|
|
|
await _context.SaveChangesAsync(User.GetUserId());
|
|
|
|
|
return RedirectToAction("Index");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|