public static Result <BankPosting> Create( decimal amount, DateTime dueDate, DateTime?documentDate, string documentNumber, Creditor creditor, string description, BankAccount bankAccount, Category category, DateTime?paymentDate, BankPostingType type) { var totalAmountResult = Amount.Create(amount); var dueDateResult = DueDate.Create(dueDate); var documentDateResult = GetDocumentDate(documentDate); var documentNumberResult = GetDocumentNumber(documentNumber); var descriptionResult = Description.Create(description); var paymentDateResult = GetPaymentDate(paymentDate); var result = Result.Combine( totalAmountResult, dueDateResult, documentDateResult, documentNumberResult, descriptionResult, paymentDateResult); if (result.IsSuccess) { return(Result.Success <BankPosting>( new BankPosting( amount: totalAmountResult.Value, dueDate: dueDateResult.Value, creditor: creditor, description: descriptionResult.Value, documentDate: documentDateResult.Value, documentNumber: documentNumberResult.Value, bankAccount: bankAccount, catgory: category, paymentDate: paymentDateResult.Value, type: type))); } return(Result .Failure <BankPosting>(result.Error)); }
public BankPosting( Amount amount, DueDate dueDate, Creditor creditor, Description description, Maybe <DocumentDate> documentDate, Maybe <DocumentNumber> documentNumber, BankAccount bankAccount, Category catgory, Maybe <PaymentDate> paymentDate, BankPostingType type) { Amount = amount; DueDate = dueDate; Description = description; DocumentDate = documentDate; DocumentNumber = documentNumber; BankAccount = bankAccount; Cateogry = catgory; PaymentDate = paymentDate; Creditor = creditor; Type = type; }