Skip to content

Commit

Permalink
Update Controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
Elyas-Amini committed Nov 23, 2023
1 parent e6307ab commit ec7979e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ namespace EasyMicroservices.SupportsMicroservice.WebApi.Controllers
{
public class TicketAssignController : SimpleQueryServiceController<TicketAssignEntity, CreateTicketAssignRequestContract, UpdateTicketAssignRequestContract, TicketAssignContract, long>
{
private readonly IContractLogic<TicketAssignEntity, CreateTicketAssignRequestContract, UpdateTicketAssignRequestContract, TicketAssignContract, long> _contractlogic;
private readonly IContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long> _ticketlogic;
public IUnitOfWork _uow;

public TicketAssignController(IUnitOfWork uow) : base(uow)
{
_uow = uow;
_contractlogic = uow.GetContractLogic<TicketAssignEntity, CreateTicketAssignRequestContract, UpdateTicketAssignRequestContract, TicketAssignContract, long>();
_ticketlogic = uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
}
public override async Task<MessageContract<long>> Add(CreateTicketAssignRequestContract request, CancellationToken cancellationToken = default)
{
var _ticketlogic = _uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
var _contractlogic = _uow.GetContractLogic<TicketAssignEntity, CreateTicketAssignRequestContract, UpdateTicketAssignRequestContract, TicketAssignContract, long>();
var checkTicketId = await _ticketlogic.GetById(new GetIdRequestContract<long>(){ Id = request.TicketId});
if (checkTicketId.IsSuccess)
return await _contractlogic.Add(request, cancellationToken);
return (EasyMicroservices.ServiceContracts.FailedReasonType.Empty, "TicketId is incorrect");
}
public override async Task<MessageContract<TicketAssignContract>> Update(UpdateTicketAssignRequestContract request, CancellationToken cancellationToken = default)
{
var _ticketlogic = _uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
var _contractlogic = _uow.GetContractLogic<TicketAssignEntity, CreateTicketAssignRequestContract, UpdateTicketAssignRequestContract, TicketAssignContract, long>();
var checkTicketId = await _ticketlogic.GetById(new GetIdRequestContract<long>() { Id = request.TicketId });
if (checkTicketId.IsSuccess)
return await _contractlogic.Update(request, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ namespace EasyMicroservices.SupportsMicroservice.WebApi.Controllers
{
public class TicketController : SimpleQueryServiceController<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>
{
private readonly IContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long> _contractlogic;
public IUnitOfWork _uow;


public TicketController(IUnitOfWork uow) : base(uow)
{
_uow = uow;
_contractlogic = uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@ namespace EasyMicroservices.SupportsMicroservice.WebApi.Controllers
{
public class TicketDepartmentController : SimpleQueryServiceController<TicketDepartmentEntity, CreateTicketDepartmentRequestContract, UpdateTicketDepartmentRequestContract, TicketDepartmentContract, long>
{
private readonly IContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long> _ticketlogic;
private readonly IContractLogic<DepartmentEntity, CreateDepartmentRequestContract, UpdateDepartmentRequestContract, DepartmentContract, long> _departmentlogic;
private readonly IContractLogic<TicketDepartmentEntity, CreateTicketDepartmentRequestContract, UpdateTicketDepartmentRequestContract, TicketDepartmentContract, long> _contractlogic;
public IUnitOfWork _uow;

public TicketDepartmentController(IUnitOfWork uow) : base(uow)
{
_uow = uow;
_ticketlogic = uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
_departmentlogic = uow.GetContractLogic<DepartmentEntity, CreateDepartmentRequestContract, UpdateDepartmentRequestContract, DepartmentContract, long>();
_contractlogic = uow.GetContractLogic<TicketDepartmentEntity, CreateTicketDepartmentRequestContract, UpdateTicketDepartmentRequestContract, TicketDepartmentContract, long>();
}
public override async Task<MessageContract<long>> Add(CreateTicketDepartmentRequestContract request, CancellationToken cancellationToken = default)
{
var _ticketlogic = _uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
var _departmentlogic = _uow.GetContractLogic<DepartmentEntity, CreateDepartmentRequestContract, UpdateDepartmentRequestContract, DepartmentContract, long>();
var _contractlogic = _uow.GetContractLogic<TicketDepartmentEntity, CreateTicketDepartmentRequestContract, UpdateTicketDepartmentRequestContract, TicketDepartmentContract, long>();
var checkTicketId = await _ticketlogic.GetById(new GetIdRequestContract<long>() { Id = request.TicketId });
var checkDepartmentID = await _departmentlogic.GetById(new GetIdRequestContract<long>() { Id = request.DepartmentId });
if (checkTicketId.IsSuccess && checkDepartmentID.IsSuccess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ namespace EasyMicroservices.SupportsMicroservice.WebApi.Controllers
{
public class TicketHistoryController : SimpleQueryServiceController<TicketHistoryEntity, CreateTicketHistoryRequestContract, UpdateTicketHistoryRequestContract, TicketHistoryContract, long>
{
private readonly IContractLogic<TicketHistoryEntity, CreateTicketHistoryRequestContract, UpdateTicketHistoryRequestContract, TicketHistoryContract, long> _contractlogic;
private readonly IContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long> _ticketlogic;
public IUnitOfWork _uow;

public TicketHistoryController(IUnitOfWork uow) : base(uow)
{
_uow = uow;
_contractlogic = uow.GetContractLogic<TicketHistoryEntity, CreateTicketHistoryRequestContract, UpdateTicketHistoryRequestContract, TicketHistoryContract, long>();
_ticketlogic = uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
}
public override async Task<MessageContract<long>> Add(CreateTicketHistoryRequestContract request, CancellationToken cancellationToken = default)
{
var _contractlogic = _uow.GetContractLogic<TicketHistoryEntity, CreateTicketHistoryRequestContract, UpdateTicketHistoryRequestContract, TicketHistoryContract, long>();
var _ticketlogic = _uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
var checkTicketId = await _ticketlogic.GetById(new GetIdRequestContract<long>() { Id = request.TicketId });
if (checkTicketId.IsSuccess)
return await _contractlogic.Add(request, cancellationToken);
Expand All @@ -31,6 +29,8 @@ public override async Task<MessageContract<long>> Add(CreateTicketHistoryRequest
}
public override async Task<MessageContract<TicketHistoryContract>> Update(UpdateTicketHistoryRequestContract request, CancellationToken cancellationToken = default)
{
var _contractlogic = _uow.GetContractLogic<TicketHistoryEntity, CreateTicketHistoryRequestContract, UpdateTicketHistoryRequestContract, TicketHistoryContract, long>();
var _ticketlogic = _uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
var checkTicketId = await _ticketlogic.GetById(new GetIdRequestContract<long>() { Id = request.TicketId });
if (checkTicketId.IsSuccess)
return await _contractlogic.Update(request, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ namespace EasyMicroservices.SupportsMicroservice.WebApi.Controllers
{
public class TicketSupportTimeHistoryController : SimpleQueryServiceController<TicketSupportTimeHistoryEntity, CreateTicketSupportTimeHistoryRequestContract, UpdateTicketSupportTimeHistoryRequestContract, TicketSupportTimeHistoryContract, long>
{
private readonly IContractLogic<TicketSupportTimeHistoryEntity, CreateTicketSupportTimeHistoryRequestContract, UpdateTicketSupportTimeHistoryRequestContract, TicketSupportTimeHistoryContract, long> _contractlogic;
private readonly IContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long> _ticketlogic;
public IUnitOfWork _uow;

public TicketSupportTimeHistoryController(IUnitOfWork uow) : base(uow)
{
_uow = uow;
_contractlogic = uow.GetContractLogic<TicketSupportTimeHistoryEntity, CreateTicketSupportTimeHistoryRequestContract, UpdateTicketSupportTimeHistoryRequestContract, TicketSupportTimeHistoryContract, long>();
_ticketlogic = uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
}
public override async Task<MessageContract<long>> Add(CreateTicketSupportTimeHistoryRequestContract request, CancellationToken cancellationToken = default)
{
var _ticketlogic = _uow.GetContractLogic<TicketEntity, CreateTicketRequestContract, UpdateTicketRequestContract, TicketContract, long>();
var checkTicketId = await _ticketlogic.GetById(new GetIdRequestContract<long>() { Id = request.TicketId });
if (checkTicketId.IsSuccess)
return await base.Add(request, cancellationToken);
Expand Down

0 comments on commit ec7979e

Please sign in to comment.