Exemplo n.º 1
0
 /// <summary>
 /// Gets the core filter from this model.
 /// </summary>
 /// <returns>Filter.</returns>
 public ActFilter GetFilter(ITextFilter filter)
 {
     return(new ActFilter
     {
         PageNumber = PageNumber,
         PageSize = PageSize,
         ArchiveId = ArchiveId.GetValueOrDefault(),
         BookId = BookId.GetValueOrDefault(),
         BookYearMin = BookYearMin.GetValueOrDefault(),
         BookYearMax = BookYearMax.GetValueOrDefault(),
         Description = filter.Apply(Description),
         ActTypeId = ActTypeId.GetValueOrDefault(),
         FamilyId = FamilyId.GetValueOrDefault(),
         CompanyId = CompanyId.GetValueOrDefault(),
         PlaceId = PlaceId.GetValueOrDefault(),
         Label = filter.Apply(Label),
         CategoryIds = ParseIds(CategoryIds),
         ProfessionIds = ParseIds(ProfessionIds),
         PartnerIds = ParseIds(PartnerIds)
     });
 }
Exemplo n.º 2
0
        public string BuildLookup(DataEntityType type, string filter, int top)
        {
            string filterx      = _filter.Apply(filter);
            string table        = GetTableName(type);
            string field        = GetTableLookupFieldName(type);
            string displayField = field.EndsWith("x")
                ? field.Substring(0, field.Length - 1)
                : field;

            StringBuilder sb = new StringBuilder("SELECT DISTINCT ");

            sb.Append(ET("id"))
            .Append(',')
            .Append(ET(displayField))
            .Append(" AS n FROM ")
            .AppendLine(ET(table));

            switch (type)
            {
            case DataEntityType.Partner:
                sb.AppendLine("INNER JOIN actPartner ON " +
                              "person.id=actPartner.partnerId");
                break;
            }

            if (!string.IsNullOrEmpty(filterx))
            {
                sb.Append("WHERE ")
                .Append(ETP(table, field))
                .Append(" LIKE '%")
                .Append(SqlHelper.SqlEncode(filterx))
                .AppendLine("%'");
            }
            sb.Append("ORDER BY ").Append(ET(displayField));

            if (top > 0)
            {
                sb.Append(" LIMIT ").Append(top);
            }
            sb.AppendLine(";");

            return(sb.ToString());
        }
Exemplo n.º 3
0
        private EfArchive GetArchive(string name, CensusDbContext db)
        {
            if (name == null)
            {
                return(null);
            }

            string    namex   = _indexFilter.Apply(name);
            EfArchive archive = db.Archives.FirstOrDefault(a => a.Namex == namex);

            if (archive == null)
            {
                archive = new EfArchive
                {
                    Name  = name,
                    Namex = namex
                };
                db.Archives.Add(archive);
                db.SaveChanges();
            }

            LogMaxLengthErrors(archive);
            return(archive);
        }