Exemplo n.º 1
0
        private EfBookSubtype GetBookSubtype(string name, int bookTypeId,
                                             CensusDbContext db)
        {
            if (name == null)
            {
                return(null);
            }

            string        namex = _indexFilter.Apply(name);
            EfBookSubtype sub   = db.BookSubtypes.FirstOrDefault(
                s => s.BookTypeId == bookTypeId && s.Namex == namex);

            if (sub == null)
            {
                sub = new EfBookSubtype
                {
                    Name       = name,
                    Namex      = namex,
                    BookTypeId = bookTypeId
                };
                db.BookSubtypes.Add(sub);
                db.SaveChanges();
            }

            LogMaxLengthErrors(sub);
            return(sub);
        }
Exemplo n.º 2
0
        private Tuple <EfCategory, bool> GetCategory(string name, CensusDbContext db)
        {
            if (name == null)
            {
                return(null);
            }

            bool unsure = false;

            if (name.EndsWith("?"))
            {
                unsure = true;
                name   = name[0..^ 1];
Exemplo n.º 3
0
        private EfCompany GetCompany(string name, string prevName,
                                     CensusDbContext db)
        {
            if (name == null)
            {
                return(null);
            }

            string    namex   = _indexFilter.Apply(name);
            EfCompany company = db.Companies.FirstOrDefault(c => c.Namex == namex);

            if (company == null)
            {
                company = new EfCompany
                {
                    Name  = name,
                    Namex = namex
                };
                db.Companies.Add(company);
                db.SaveChanges();
            }

            if (!string.IsNullOrEmpty(prevName))
            {
                namex = _indexFilter.Apply(prevName);
                EfCompany prevCompany =
                    db.Companies.FirstOrDefault(c => c.Namex == namex);
                if (prevCompany == null)
                {
                    prevCompany = new EfCompany
                    {
                        Name  = prevName,
                        Namex = namex
                    };
                    db.Companies.Add(prevCompany);
                    db.SaveChanges();
                }
                LogMaxLengthErrors(prevCompany);
                company.Previous = prevCompany;
            }

            LogMaxLengthErrors(company);
            return(company);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        private EfPerson GetPerson(string name, CensusDbContext db)
        {
            if (name == null)
            {
                return(null);
            }

            string   namex  = _indexFilter.Apply(name);
            EfPerson person = db.Persons.FirstOrDefault(p => p.Namex == namex);

            if (person == null)
            {
                person = new EfPerson
                {
                    Name  = name,
                    Namex = namex
                };
                db.Persons.Add(person);
                db.SaveChanges();
            }

            LogMaxLengthErrors(person);
            return(person);
        }
Exemplo n.º 6
0
        private EfPlace GetPlace(string name, CensusDbContext db)
        {
            if (name == null)
            {
                return(null);
            }

            string  namex = _indexFilter.Apply(name);
            EfPlace place = db.Places.FirstOrDefault(c => c.Namex == namex);

            if (place == null)
            {
                place = new EfPlace
                {
                    Name  = name,
                    Namex = namex
                };
                db.Places.Add(place);
                db.SaveChanges();
            }

            LogMaxLengthErrors(place);
            return(place);
        }
Exemplo n.º 7
0
        private EfBookType GetBookType(string name, CensusDbContext db)
        {
            if (name == null)
            {
                return(null);
            }

            string     namex = _indexFilter.Apply(name);
            EfBookType type  = db.BookTypes.FirstOrDefault(t => t.Namex == namex);

            if (type == null)
            {
                type = new EfBookType
                {
                    Name  = name,
                    Namex = namex
                };
                db.BookTypes.Add(type);
                db.SaveChanges();
            }

            LogMaxLengthErrors(type);
            return(type);
        }
Exemplo n.º 8
0
        private EfFamily GetFamily(string name, CensusDbContext db)
        {
            if (name == null)
            {
                return(null);
            }

            string   namex  = _indexFilter.Apply(name);
            EfFamily family = db.Families.FirstOrDefault(f => f.Namex == namex);

            if (family == null)
            {
                family = new EfFamily
                {
                    Name  = name,
                    Namex = namex
                };
                db.Families.Add(family);
                db.SaveChanges();
            }

            LogMaxLengthErrors(family);
            return(family);
        }
Exemplo n.º 9
0
        private EfBook GetBook(int archiveId, string location, CensusDbContext db)
        {
            if (location == null)
            {
                return(null);
            }

            string locationx = _indexFilter.Apply(location);
            EfBook book      = db.Books.FirstOrDefault(b => b.ArchiveId == archiveId &&
                                                       b.Locationx == location);

            if (book == null)
            {
                book = new EfBook
                {
                    ArchiveId = archiveId,
                    Location  = location,
                    Locationx = locationx
                };
                db.Books.Add(book);
            }

            return(book);
        }
Exemplo n.º 10
0
 public PersonRepo(CensusDbContext context, ILogger <PersonRepo> logger)
 {
     _context = context;
     _logger  = logger;
 }
Exemplo n.º 11
0
 public CensusController(CensusDbContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
Exemplo n.º 12
0
 public CensusRepository(CensusDbContext censusDbContext)
 {
     this.censusDbContext = censusDbContext;
 }