public Task <T> GetRecruitingContract <T>(IRecruitingAgencyOwner ao, Guid contractId) where T : AgencyOwnerRecruitingContractOutput { return(Repository.Queryable().ForAgencyOwner(ao) .FindById(contractId) .ProjectTo <T>(ProjectionMapping) .FirstOrDefaultAsync()); }
public Task <T> GetAgreement <T>(IRecruitingAgencyOwner principal, Guid providerAgencyId) where T : RecruitingAgreementOutput { return(Repository.Queryable().Where(x => x.RecruitingOrganizationId == principal.OrganizationId && x.ProviderOrganizationId == providerAgencyId) .Where(x => x.Status != AgreementStatus.Rejected) .ProjectTo <T>(ProjectionMapping) .FirstOrDefaultAsync()); }
public Task <PackedList <T> > GetRecruitingContracts <T>(IRecruitingAgencyOwner ao, ContractFilters filters) where T : AgencyOwnerRecruitingContractOutput { return(Repository.Queryable().ForAgencyOwner(ao) .ApplyWhereFilters(filters) .OrderByDescending(x => x.Updated) .PaginateProjection <Contract, T>(filters, ProjectionMapping)); }
public async Task <RecruitingAgencyOwnerChartOutput> GetRecruitingChartData(IRecruitingAgencyOwner owner, TimeMatrixFilters filters, ChartParams chartParams) { var result = await _matrixService.GetRecruitingAgencyComposedOutput(owner, filters); var status = result.Matrix .ToStatusData <RecruitingAgencyOwnerTimeMatrixOutput, RecruitingAgencyOwnerChartDataItem>() .FillMissingDays(chartParams.DateBreakdown, filters).TopLevelGrouping(chartParams.DateBreakdown) .SecondLevelGrouping(chartParams.DateBreakdown); var re = result.Matrix.ToReData <RecruitingAgencyOwnerTimeMatrixOutput, AgencyOwnerOrganizationRecruiterOutput, RecruitingAgencyOwnerChartDataItem>(result.Recruiters). FillMissingDays(chartParams.DateBreakdown, filters). TopLevelGrouping(chartParams.DateBreakdown). SecondLevelGrouping(chartParams.DateBreakdown); return(new RecruitingAgencyOwnerChartOutput { Re = re, Status = status, CurrentBreakdown = "re", CurrentDateRange = chartParams.DateBreakdown == DateBreakdown.ByMonth ? "m0" : "w0", DateRanges = GetDateRange(chartParams.DateBreakdown, re), Breakdowns = new Dictionary <string, string> { { "re", "By Recruiter" }, { "status", "By Status" } } }); }
public Task <List <T> > GetAgreements <T>(IRecruitingAgencyOwner principal) where T : RecruitingAgreementOutput { return(Repository.Queryable().Where(x => x.RecruitingOrganizationId == principal.OrganizationId) .Where(x => x.Status != AgreementStatus.Rejected) .ProjectTo <T>(ProjectionMapping) .ToListAsync()); }
public async Task <List <T> > Discover <T>(IRecruitingAgencyOwner owner) where T : RecruitingAgencyOwnerProviderOrganizationOutput { var exclude = await _recruitingAgreement.Queryable() .Where(x => x.RecruitingOrganizationId == owner.OrganizationId) .Select(x => x.ProviderOrganizationId).ToListAsync(); exclude.Add(owner.OrganizationId); return(await Repository.Queryable() .Include(x => x.Organization) .ThenInclude(x => x.OrganizationFinancialAccount) .Where(x => !exclude.Contains(x.Id) && x.Organization.OrganizationFinancialAccount != null && x.Discoverable) .ProjectTo <T>(ProjectionMapping).ToListAsync()); }
public async Task <OrganizationResult> UpdateOrganization(IRecruitingAgencyOwner agencyOwner, RecruitingOrganizationInput input) { _logger.LogInformation(GetLogMessage("Organization:{0}; input:{@input}"), agencyOwner.OrganizationId, input); var recruitingOrganization = await Repository.Queryable() .Include(x => x.RecruitingOrganization) .Include(x => x.Recruiters) .Where(x => x.Id == agencyOwner.OrganizationId) .Select(x => x.RecruitingOrganization) .FirstAsync(); var organization = await Repository.Queryable() .Where(x => x.Id == agencyOwner.OrganizationId) .FirstOrDefaultAsync(); return(await UpdateRecruitingOrganization(recruitingOrganization, input, organization)); }
public async Task <ContractResult> UpdateContract(IRecruitingAgencyOwner ao, Guid contractId, UpdateRecruitingContractInput input) { var co = await Repository.Queryable().ForAgencyOwner(ao) .FirstAsync(x => x.Id == contractId); co.InjectFrom <NullableInjection>(input); if (input.RecruiterStream.HasValue) { co.MarketerStream = input.RecruiterStream.Value; } if (input.RecruitingAgencyStream.HasValue) { co.MarketingAgencyStream = input.RecruitingAgencyStream.Value; } return(await UpdateContract(co)); }
public async Task <AgreementResult> AcceptAgreement(IRecruitingAgencyOwner principal, Guid providerOrganizationId) { _logger .LogInformation(GetLogMessage("Accepting Agreement: Recruiting Agency {1}, Provider Agency {2}"), principal.OrganizationId, providerOrganizationId); var agreement = await Repository.Queryable() .FirstOrDefaultAsync(x => x.RecruitingOrganizationId == principal.OrganizationId && x.ProviderOrganizationId == providerOrganizationId); if (agreement == null) { throw new ApplicationException("Agreement not found"); } ; if (agreement.Status != AgreementStatus.AwaitingApproval) { return new AgreementResult() { Succeeded = false } } ; agreement.Status = AgreementStatus.Approved; agreement.ObjectState = ObjectState.Modified; agreement.Updated = DateTimeOffset.UtcNow; var result = await Repository.UpdateAsync(agreement, true); _logger.LogDebug(GetLogMessage("{0} Records updated in database"), result); return(new AgreementResult() { Succeeded = result > 0, RecruitingOrganizationId = agreement.RecruitingOrganizationId, ProviderOrganizationId = agreement.ProviderOrganizationId }); }
public async Task <RecruitingAgencyOwnerTimeMatrixComposedOutput> GetRecruitingAgencyComposedOutput(IRecruitingAgencyOwner owner, TimeMatrixFilters filters) { // this is essentially the provider organization id filters.RecruiterOrganizationId = owner.OrganizationId; var matrix = await _context.TimeMatrix.ApplyWhereFilters(filters) .ProjectTo <RecruitingAgencyOwnerTimeMatrixOutput>(_mapperConfiguration) .ToListAsync(); var uniqueRecruiterIds = matrix.Select(x => x.RecruiterId).Distinct().ToArray(); var recruiters = _recruiterService.GetForOrganization <AgencyOwnerOrganizationRecruiterOutput>(owner.OrganizationId, uniqueRecruiterIds); Task.WaitAll(recruiters); return(new RecruitingAgencyOwnerTimeMatrixComposedOutput { Matrix = matrix, Recruiters = recruiters.Result }); }
public async Task <AgreementResult> CreateAgreement(IRecruitingAgencyOwner principal, Guid providerOrganizationId, RecruitingAgreementInput input) { _logger.LogInformation(GetLogMessage("Agency Owner creating recruiting agreement {@agreement}"), input); var retVal = new AgreementResult() { ProviderOrganizationId = providerOrganizationId, RecruitingOrganizationId = principal.OrganizationId }; var recruiterOrganization = await _recruitingOrganizations.Queryable() .Where(x => x.Id == principal.OrganizationId) .FirstOrDefaultAsync(); if (recruiterOrganization == null) { retVal.ErrorMessage = "Organization is not configured correctly"; return(retVal); } _logger.LogDebug(GetLogMessage("Recruiter Organization Found: {0}"), recruiterOrganization.Id); var providerOrganization = await _providerOrganizations.Queryable() .Where(x => x.Id == providerOrganizationId) .FirstOrDefaultAsync(); if (providerOrganization == null) { throw new ApplicationException("Provider organization was not found"); } _logger.LogDebug(GetLogMessage("Provider Organization Found: {0}"), providerOrganization.Id); var agreement = new RecruitingAgreement() { RecruiterStream = recruiterOrganization.RecruiterStream, RecruiterBonus = recruiterOrganization.RecruiterBonus, RecruitingAgencyBonus = recruiterOrganization.RecruitingAgencyBonus, RecruitingAgencyStream = recruiterOrganization.RecruitingAgencyStream, RecruitingOrganizationId = principal.OrganizationId, ProviderOrganizationId = providerOrganizationId, Status = AgreementStatus.AwaitingApproval, ObjectState = ObjectState.Added, InitiatedByProvider = false }; _logger.LogDebug(GetLogMessage("Recruiting Agreement: {@agreement}"), agreement); var result = Repository.InsertOrUpdateGraph(agreement, true); _logger.LogDebug(GetLogMessage("{0} Records updated in database"), result); return(await Task.FromResult(new AgreementResult() { Succeeded = result > 0, ProviderOrganizationId = agreement.ProviderOrganizationId, RecruitingOrganizationId = agreement.RecruitingOrganizationId })); }
public Task <AgencyOwnerRecruitingOrganizationDetailsOutput> GetRecruitingDetails(IRecruitingAgencyOwner agencyOwner) { return(Repository.Queryable() .Include(x => x.RecruitingOrganization) .Where(x => x.RecruitingOrganization != null && x.Id == agencyOwner.OrganizationId) .Select(x => x.RecruitingOrganization) .ProjectTo <AgencyOwnerRecruitingOrganizationDetailsOutput>(ProjectionMapping) .FirstOrDefaultAsync()); }
public static IQueryable <Contract> ForAgencyOwner(this IQueryable <Contract> entities, IRecruitingAgencyOwner ao) { return(entities.Where(x => x.RecruiterOrganizationId == ao.OrganizationId)); }
public RecruitingAgreementController(IServiceProvider serviceProvider, IRecruitingAgencyOwner recruitingAgencyOwner, IRecruitingAgreementService agreementService) : base(serviceProvider) { _recruitingAgencyOwner = recruitingAgencyOwner; _agreementService = agreementService; }