Пример #1
0
        public FinancialAccountDocument GetMostRecentDocument(FinancialAccountDocumentType documentType)
        {
            FinancialAccountDocuments documents = FinancialAccountDocuments.ForAccount(this, documentType);

            if (documents.Count() > 0)
            {
                return(documents.Last());
            }

            return(null);
        }
Пример #2
0
 public static FinancialAccountDocument Create(FinancialAccount account, FinancialAccountDocumentType documentType, Person uploader, DateTime concernsStart, DateTime concernsEnd, string rawText)
 {
     return(FromIdentityAggressive(
                SwarmDb.GetDatabaseForWriting().CreateFinancialAccountDocument(
                    account.Identity,
                    documentType,
                    uploader == null? 0: uploader.Identity,
                    concernsStart,
                    concernsEnd,
                    rawText
                    )));
 }
 public BasicFinancialAccountDocument(int financialAccountDocumentId, int financialAccountId,
                                      FinancialAccountDocumentType type, DateTime uploadedDateTime, int uploadedByPersonId,
                                      DateTime concernsPeriodStart, DateTime concernsPeriodEnd, string rawDocumentText)
 {
     this.FinancialAccountDocumentId = financialAccountDocumentId;
     this.FinancialAccountId         = financialAccountId;
     this.Type                = type;
     this.UploadedDateTime    = uploadedDateTime;
     this.UploadedByPersonId  = uploadedByPersonId;
     this.ConcernsPeriodStart = concernsPeriodStart;
     this.ConcernsPeriodEnd   = concernsPeriodEnd;
     this.RawDocumentText     = rawDocumentText;
 }
        private static BasicFinancialAccountDocument ReadFinancialAccountDocumentFromDataReader(IDataRecord reader)
        {
            int      financialAccountDocumentId         = reader.GetInt32(0);
            int      financialAccountId                 = reader.GetInt32(1);
            string   financialAccountDocumentTypeString = reader.GetString(2);
            DateTime uploadedDateTime    = reader.GetDateTime(3);
            int      uploadedByPersonId  = reader.GetInt32(4);
            DateTime concernsPeriodStart = reader.GetDateTime(5);
            DateTime concernsPeriodEnd   = reader.GetDateTime(6);
            string   rawText             = reader.GetString(7);

            FinancialAccountDocumentType docType = (FinancialAccountDocumentType)Enum.Parse(typeof(FinancialAccountDocumentType), financialAccountDocumentTypeString);

            return(new BasicFinancialAccountDocument(financialAccountDocumentId, financialAccountId, docType, uploadedDateTime, uploadedByPersonId, concernsPeriodStart,
                                                     concernsPeriodEnd, rawText));
        }
        public int CreateFinancialAccountDocument(int financialAccountId, FinancialAccountDocumentType type, int uploadedByPersonId,
                                                  DateTime concernsPeriodStart, DateTime concernsPeriodEnd, string rawText)
        {
            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();

                DbCommand command = GetDbCommand("CreateFinancialAccountDocument", connection);
                command.CommandType = CommandType.StoredProcedure;

                AddParameterWithName(command, "financialAccountId", financialAccountId);
                AddParameterWithName(command, "financialAccountDocumentType", type.ToString());
                AddParameterWithName(command, "uploadedDateTime", DateTime.UtcNow);
                AddParameterWithName(command, "uploadedByPersonId", uploadedByPersonId);
                AddParameterWithName(command, "concernsPeriodStart", concernsPeriodStart); // inclusive endpoint
                AddParameterWithName(command, "concernsPeriodEnd", concernsPeriodEnd);     // exclusive endpoint
                AddParameterWithName(command, "rawDocumentText", rawText);

                return(Convert.ToInt32(command.ExecuteScalar()));
            }
        }
Пример #6
0
        public static FinancialAccountDocuments ForAccount(FinancialAccount account, FinancialAccountDocumentType typeRequested = FinancialAccountDocumentType.Unknown)
        {
            FinancialAccountDocuments result = FromArray(SwarmDb.GetDatabaseForReading().GetFinancialAccountDocuments(account));

            result.Sort(new FinancialAccountDocumentsSorterByTypeThenDate());

            if (typeRequested != FinancialAccountDocumentType.Unknown)
            {
                FinancialAccountDocuments subset = new FinancialAccountDocuments();

                foreach (FinancialAccountDocument document in result)
                {
                    if (document.Type == typeRequested)
                    {
                        subset.Add(document);
                    }
                }

                return(subset);
            }

            return(result);
        }