Equipment is kész.
This commit is contained in:
@@ -1,12 +1,49 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Pages.BaseStock.Equipments
|
||||
{
|
||||
public class EquipmentEditPageModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IBaseStockService _baseStockService;
|
||||
|
||||
[BindProperty]
|
||||
public EquipmentDTO EquipmentDTO { get; set; }
|
||||
|
||||
public EquipmentEditPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService)
|
||||
{
|
||||
_baseStockService = baseStockService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task OnGet(int id)
|
||||
{
|
||||
EquipmentDTO = await _baseStockService.GetEquipment(id);
|
||||
}
|
||||
public async Task<IActionResult> OnPostSave([FromBody] EquipmentDTO equipmentDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _baseStockService.UpdateEquipment(equipmentDTO);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return new JsonResult(new { success = true });
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user