public LeaveWithInmateSpecification(LeavesFilter filter) : base(x => (!filter.LeaveId.HasValue || x.Id == filter.LeaveId) && (!filter.InmateId.HasValue || x.InmateId == filter.InmateId) ) { AddInclude(x => x.Inmate); }
public async Task <ActionResult <IReadOnlyList <LeaveDto> > > GetLeaves(int tenantId) { var filter = new LeavesFilter { InmateId = tenantId }; var spec = new LeaveWithInmateSpecification(filter); return(Ok(await _unitOfWork.Repository <Leave>().FindAllBySpecAsync <LeaveDto>(spec))); }
public async Task <ActionResult <LeaveDto> > GetLeave(int id) { var filter = new LeavesFilter { LeaveId = id }; var spec = new LeaveWithInmateSpecification(filter); return(await _unitOfWork.Repository <Leave>().FindOneBySpecAsync <LeaveDto>(spec)); }