Ejemplo n.º 1
0
 public OpportunityResponseBusiness(ILookupService lookupService, IFileService fileService, INotifyService notifyService, IKeyValueService keyValueService, IOpportunityResponseService opportunityResponseService, IOpportunityService opportunityService, IMapper mapper)
 {
     _lookupService              = lookupService;
     _fileService                = fileService;
     _notifyService              = notifyService;
     _keyValueService            = keyValueService;
     _opportunityResponseService = opportunityResponseService;
     _opportunityService         = opportunityService;
     _mapper = mapper;
 }
Ejemplo n.º 2
0
 public OpportunityResponseApplyRequestValidator(ILookupService lookupService, IOpportunityService opportunityService, IOpportunityResponseService opportunityResponseService)
 {
     RuleFor(_ => _.OpportunityId)
     .NotEmpty()
     .MustAsync(async(or, c) => {
         return(await opportunityService.GetById(or, false) != null);
     }).WithMessage("{PropertyName} does not exist.")
     .MustAsync(async(or, c) => {
         var existing = await opportunityService.GetById(or, false);
         return(!existing.ClosedAt.HasValue);
     }).WithMessage("Opportunity was closed");
     RuleFor(_ => _.Id).NotEmpty();
     RuleFor(_ => _.UserId).NotEmpty();
     RuleFor(_ => _.WhyPickMe).NotEmpty();
     RuleFor(_ => _.SubmittedAt).Empty();
     RuleFor(_ => _.ResumeUpload).Matches(@"^.+\.(?:(?:[pP][dD][fF]))$");
     RuleFor(_ => _)
     .MustAsync(async(or, c) => {
         var existing = await opportunityResponseService.Get(or.OpportunityId, or.UserId);
         return(existing != null);
     }).WithMessage("You have already applied for this opportunity.");
 }