private void CheckThereIsNoPendingTransferRequest() { if (TransferRequests.Any(x => x.Status == (byte)Types.TransferApprovalStatus.Pending)) { throw new DomainException(nameof(TransferRequests), $"Cohort already has a pending transfer request"); } }
public void AddTransferRequest(string jsonSummary, decimal cost, decimal fundingCap, Party lastApprovedByParty) { CheckThereIsNoPendingTransferRequest(); var transferRequest = new TransferRequest(); transferRequest.Status = (byte)Types.TransferApprovalStatus.Pending; transferRequest.TrainingCourses = jsonSummary; transferRequest.Cost = cost; transferRequest.FundingCap = fundingCap; TransferRequests.Add(transferRequest); TransferApprovalStatus = Types.TransferApprovalStatus.Pending; Publish(() => new TransferRequestCreatedEvent(transferRequest.Id, Id, DateTime.UtcNow, lastApprovedByParty)); }