Exemple #1
0
 public DraftApplicationUpdated(DraftApplicationId id, Content content,
                                IncidentType incidentType, List <SuspiciousEmployee> suspiciousEmployees) : base(id.Value.ToString())
 {
     this.Id                  = id;
     this.Content             = content;
     this.IncidentType        = incidentType;
     this.SuspiciousEmployees = suspiciousEmployees;
 }
Exemple #2
0
        public async void Delete(DraftApplicationId draftApplicationId)
        {
            if (draftApplicationId == null)
            {
                throw new ArgumentNullException(nameof(draftApplicationId));
            }


            var draftApplication = await this._writeContext.DraftApplication.FirstAsync(x =>
                                                                                        x.Id == draftApplicationId);

            this._writeContext.DraftApplication.Remove(draftApplication);
        }
Exemple #3
0
        public static DraftApplication Create(
            Title tile,
            Content content,
            IncidentType incidentType,
            EmployeeId applicantId,
            List <EmployeeId> suspiciousEmployees)
        {
            var id = DraftApplicationId.Create();
            var suspiciousEmployeesList = suspiciousEmployees.Select(x => new SuspiciousEmployee(x)).ToList();

            var draftApplication = new DraftApplication(id, content, tile, incidentType, applicantId, suspiciousEmployeesList);

            draftApplication.AddDomainEvent(new DraftApplicationCreated(id, content,
                                                                        incidentType, applicantId, suspiciousEmployeesList));

            return(draftApplication);
        }
Exemple #4
0
        public async Task <DraftApplication> GetById(DraftApplicationId draftApplicationId,
                                                     CancellationToken cancellationToken)
        {
            if (draftApplicationId == null)
            {
                throw new ArgumentNullException(nameof(draftApplicationId));
            }

            var draftApplication = await this._writeContext.DraftApplication
                                   .Include(nameof(DraftApplication.Attachments)).FirstAsync(x =>
                                                                                             x.Id == draftApplicationId, cancellationToken);

            if (draftApplication == null)
            {
                throw new AggregateNotFoundInDbException(nameof(Application), draftApplicationId.Value);
            }

            return(draftApplication);
        }
Exemple #5
0
        private DraftApplication(
            DraftApplicationId draftApplicationId,
            Content content,
            Title title,
            IncidentType incidentType,
            EmployeeId applicantId,
            List <SuspiciousEmployee> suspiciousEmployees)
        {
            this.CheckRule(new ApplicantCannotBeSuspectRule(suspiciousEmployees.Select(x => x.EmployeeId).ToList(), applicantId));

            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.Id          = Guard.Argument(draftApplicationId, nameof(draftApplicationId)).NotNull();

            this.IncidentType        = incidentType;
            this.SuspiciousEmployees = suspiciousEmployees;
            this.Attachments         = new List <Attachment>();
        }
Exemple #6
0
 public async Task <bool> IsExists(DraftApplicationId draftApplicationId, CancellationToken cancellationToken)
 {
     return(await this._writeContext.DraftApplication.AnyAsync(x => x.Id == draftApplicationId,
                                                               cancellationToken));
 }
Exemple #7
0
 public DraftApplicationAttachmentsAdded(DraftApplicationId draftApplicationId, List <Attachment> addedAttachments) : base(draftApplicationId.Value.ToString())
 {
     this.DraftApplicationId = draftApplicationId;
     this.AddedAttachments   = addedAttachments;
 }
Exemple #8
0
 public DraftApplicationAttachmentsDeleted(DraftApplicationId draftApplicationId, List <Attachment> deletedAttachments) : base(draftApplicationId.Value.ToString())
 {
     this.DraftApplicationId = draftApplicationId;
     this.DeletedAttachments = deletedAttachments;
 }