private IncidentApplication(IncidentApplicationId incidentApplicationId, Content content, Title title, IncidentType incidentType, EmployeeId applicantId, List <SuspiciousEmployee> suspiciousEmployees, List <Attachment> attachments, DateTime postDate, ApplicationNumber applicationNumber) { this.ApplicantId = Guard.Argument(applicantId, nameof(applicantId)).NotNull(); this.Content = Guard.Argument(content, nameof(content)).NotNull(); this.Title = Guard.Argument(title, nameof(title)).NotNull(); this.IncidentType = Guard.Argument(incidentType, nameof(incidentType)).NotNull(); this.Id = Guard.Argument(incidentApplicationId, nameof(incidentApplicationId)).NotNull(); this.PostDate = Guard.Argument(postDate, nameof(postDate)).NotDefault(); this.CheckRule(new IndicateAtLeastOneSuspectRule(suspiciousEmployees)); this.CheckRule(new ApplicantCannotBeSuspectRule(suspiciousEmployees.Select(x => x.EmployeeId).ToList(), applicantId)); this.SuspiciousEmployees = suspiciousEmployees; this.ApplicationNumber = applicationNumber; this.ApplicationState = ApplicationStateValue.Created; this.Attachments = attachments ?? new List <Attachment>(); }
public async Task <IncidentApplication> GetPostedById(IncidentApplicationId incidentApplicationId, CancellationToken cancellationToken) { if (incidentApplicationId == null) { throw new ArgumentNullException(nameof(incidentApplicationId)); } var application = await this._writeContext.IncidentApplication.FirstAsync(x => x.Id == incidentApplicationId, cancellationToken); if (application == null) { throw new AggregateNotFoundInDbException(nameof(Application), incidentApplicationId.Value); } return(application); }
public static IncidentApplication Create(Title title, Content content, IncidentType incidentType, EmployeeId applicantId, List <EmployeeId> suspiciousEmployees, List <Attachment> attachments) { var id = IncidentApplicationId.Create(); var postDate = SystemClock.Now; var applicationNumber = new ApplicationNumber(postDate, incidentType); var suspiciousEmployeesList = suspiciousEmployees.Select(x => new SuspiciousEmployee(x)).ToList(); var application = new IncidentApplication(id, content, title, incidentType, applicantId, suspiciousEmployeesList, attachments, postDate, applicationNumber); application.AddDomainEvent(new IncidentApplicationCreated(application)); return(application); }
public async Task <bool> IsExists(IncidentApplicationId incidentApplicationId, CancellationToken cancellationToken) { return(await this._writeContext.IncidentApplication.AnyAsync(x => x.Id == incidentApplicationId, cancellationToken)); }
public IncidentApplication(IncidentApplicationId id, ApplicationNumber applicationNumber) { this.Id = id; this.ApplicationNumber = applicationNumber; }
public static IncidentApplication Create(ApplicationNumber applicationNumber) { var id = IncidentApplicationId.Create(); return(new IncidentApplication(id, applicationNumber)); }