Beispiel #1
0
        public async Task <ValidationResult> Handle(RegisterNewOFXCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                return(message.ValidationResult);
            }

            var OFX = message.OFX;

            if (await _OFXRepository.GetById(OFX.Id) != null)
            {
                AddError("The OFX has already been imported.");
                return(ValidationResult);
            }

            var stmttrn = await _OFXBusiness.RemoveTranDuplicates(OFX);

            try
            {
                if (stmttrn != null && stmttrn.Count > 0)
                {
                    _OFXRepository.AddSTMTTRNCollection(stmttrn);
                }

                OFX.BANKMSGSRSV1   = null;
                OFX.SIGNONMSGSRSV1 = null;

                _OFXRepository.Add(OFX);
            }
            catch (Exception ex)
            {
                AddError(ex.Message);
                return(ValidationResult);
            }

            return(await Commit(_OFXRepository.UnitOfWork));
        }
 public async Task <OFX> GetById(string id)
 {
     return(await _OFXRepository.GetById(id));
 }