BaseController: Fix add/edit action text

This commit is contained in:
snow flurry 2023-10-18 10:23:26 -07:00
parent f7bca00ec4
commit f4552cbccf

View file

@ -100,6 +100,7 @@ namespace PhoneToolMX.Controllers
[HttpGet("New")]
public async Task<IActionResult> New()
{
ViewData["Action"] = "add";
ViewData["Title"] = $"Add new {typeof(T).Name.ToLower()}";
return await FormView(default);
}
@ -117,7 +118,7 @@ namespace PhoneToolMX.Controllers
SetMessage(
FormMessageType.Success,
$"{typeof(T).Name} {GetFriendlyName(vm)} was created."
$"{typeof(T).Name} {GetFriendlyName(new TViewModel().FromEntity(entity.Entity))} was created."
);
return RedirectToAction("Edit", new { id = entity.Entity.Id });
@ -144,6 +145,7 @@ namespace PhoneToolMX.Controllers
[HttpGet("Edit")]
public async Task<IActionResult> Edit(int id)
{
ViewData["Action"] = "update";
var model = _context.GetOwned<T>(await CurrentUser()).FirstOrDefault(o => o.Id == id);
if (model == null) return NotFound();
ViewData["Title"] = $"Editing {typeof(T).Name.ToLower()} {GetFriendlyName(new TViewModel().FromEntity(model))}";