Beispiel #1
0
 public static Validation <Exceptional <Unit> > Create(this BookTransferDto transfer, Func <DateTime> now, Func <SqlTemplate, BookTransferDao, int> commands)
 => transfer
 .CreateBookTransfer(now)
 .Map(t => t
      .CreateBookTransferDao()
      .Save(commands.Apply(GetSqlTemplate(SqlEnum.InsertIntoBookTransfers))));
Beispiel #2
0
 /// <summary>
 /// Date validation.
 /// </summary>
 public static Validation <BookTransferDto> ValidateDate(this BookTransferDto transfer, DateTime now)
 => Some(transfer)
 .Where(t => t.Date.Date > now.Date)
 .Match <Validation <BookTransferDto> >(() => Errors.TransferDateIsPast, t => t);
Beispiel #3
0
 public static Validation <BookTransfer> CreateBookTransfer(this BookTransferDto cmd, Func <DateTime> now)
 => BookTransfer.Of(now, cmd.Amount, cmd.Beneficiary, cmd.Bic, cmd.Date, cmd.DebitedAccountId, cmd.Iban, cmd.Reference, cmd.Timestamp);
Beispiel #4
0
 /// <summary>
 /// Bic code validation.
 /// </summary>
 public static Validation <BookTransferDto> ValidateBic(this BookTransferDto transfer, Regex regex)
 => Some(transfer)
 .Where(t => regex.IsMatch(t.Bic.ToUpper()))
 .Match <Validation <BookTransferDto> >(() => Errors.InvalidBic, t => t);