Compare commits
3 Commits
577acfd0ae
...
Feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
| 18867b4929 | |||
| a9df0669c6 | |||
| 5c75316f40 |
95
ServiceHost/Areas/Client/Controllers/FineController.cs
Normal file
95
ServiceHost/Areas/Client/Controllers/FineController.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Fine;
|
||||
using CompanyManagment.App.Contracts.FineSubject;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers;
|
||||
|
||||
public class FineController:ClientBaseController
|
||||
{
|
||||
private readonly IFineApplication _fineApplication;
|
||||
private readonly IFineSubjectApplication _fineSubjectApplication;
|
||||
private readonly long _workshopId;
|
||||
|
||||
public FineController(IFineApplication fineApplication, IFineSubjectApplication fineSubjectApplication,
|
||||
IAuthHelper authHelper)
|
||||
{
|
||||
_fineApplication = fineApplication;
|
||||
_fineSubjectApplication = fineSubjectApplication;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult<FinesGroupedViewModel> GetList([FromQuery]FineSearchViewModel searchModel)
|
||||
{
|
||||
searchModel.WorkshopId = _workshopId;
|
||||
var res = _fineApplication.GetSearchListAsGrouped(searchModel);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult<OperationResult> Create([FromBody]CreateFineViewModel command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
var res =_fineApplication.Create(command);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public ActionResult<OperationResult> Edit([FromBody]EditFineViewModel command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
var res = _fineApplication.Edit(command);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpGet("{id:long}")]
|
||||
public ActionResult<EditFineViewModel> Details(long id)
|
||||
{
|
||||
var res = _fineApplication.GetDetails(id);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpDelete(("{id:long}"))]
|
||||
public ActionResult<OperationResult> Remove(long id)
|
||||
{
|
||||
var res = _fineApplication.Remove(id);
|
||||
return res;
|
||||
}
|
||||
|
||||
#region FineSubject
|
||||
|
||||
[HttpGet("subject")]
|
||||
public ActionResult<List<FineSubjectViewModel>> GetList()
|
||||
{
|
||||
var res = _fineSubjectApplication.GetAll(_workshopId);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("subject/{id:long}")]
|
||||
public ActionResult<OperationResult> CreateSubject(CreateFineSubjectViewModel command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
var res = _fineSubjectApplication.Create(command);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPut("subject/{id:long}")]
|
||||
public ActionResult<OperationResult> EditSubject(EditFineSubjectViewModel command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
var res = _fineSubjectApplication.Edit(command);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpDelete("subject/{id:long}")]
|
||||
public ActionResult<OperationResult> RemoveSubject(long id)
|
||||
{
|
||||
var res = _fineSubjectApplication.Delete(id);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user