예제 #1
0
파일: Program.cs 프로젝트: Wreynk/CDCS-API
        private static int SaveOrganisationsToDb(OrganisationsInput organisations, CategoriesInput categories)
        {
            var changes = 0;

            using (var context = new CdcsContext()) {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                context.Organisations.AddRange(organisations.Organisations);
                context.Accreditors.AddRange(organisations.Accreditors);
                context.Accreditations.AddRange(organisations.Accreditations);
                context.ContactModes.AddRange(organisations.ContactModes);
                context.GeographicalZones.AddRange(organisations.GeographicalZones);
                context.OrganisationLanguages.AddRange(organisations.OrganisationLanguages);
                context.OrganisationLegalStatuses.AddRange(organisations.OrganisationLegalStatuses);
                context.Languages.AddRange(organisations.Languages);

                context.Sectors.AddRange(categories.Sectors);
                context.Topics.AddRange(categories.Topics);
                context.Categories.AddRange(categories.Categories);
                context.SectorCategoriesHierarchies.AddRange(categories.SectorCategoriesHierarchies);

                changes = context.SaveChanges();
            }

            return(changes);
        }
예제 #2
0
        public static IQueryable <Accreditor> AllIncluding(params Expression <Func <Accreditor, object> >[] includeProperties)
        {
            using (var context = new CdcsContext())
            {
                IQueryable <Accreditor> qry = context.Accreditors;

                foreach (var includeProperty in includeProperties)
                {
                    qry = qry.Include(includeProperty);
                }
                return(qry);
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: Wreynk/CDCS-API
        private static int SaveToDb(IReadOnlyCollection <ICdcsIdentity> cdcs_objects)
        {
            var types         = cdcs_objects.Select(o => o.GetType()).Distinct();
            var nb_of_changes = 0;

            using (var context = new CdcsContext()) {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                // context.Database.Migrate();

                foreach (var t in types)
                {
                    switch (t.Name)
                    {
                    case "CdcsActionZone":
                        context.CdcsActionZones.AddRange(GetCdcsObjectByType <CdcsActionZone>(cdcs_objects));
                        break;

                    case "CdcsAccreditationType":
                        context.CdcsAccreditationTypes.AddRange(GetCdcsObjectByType <CdcsAccreditationType>(cdcs_objects));
                        break;

                    case "CdcsAccreditor":
                        context.CdcsAccreditors.AddRange(GetCdcsObjectByType <CdcsAccreditor>(cdcs_objects));
                        break;

                    case "CdcsLanguage":
                        context.CdcsLanguages.AddRange(GetCdcsObjectByType <CdcsLanguage>(cdcs_objects));
                        break;

                    case "CdcsLegalStatus":
                        context.CdcsLegalStatuses.AddRange(GetCdcsObjectByType <CdcsLegalStatus>(cdcs_objects));
                        break;

                    case "CdcsSector":
                        context.CdcsSectors.AddRange(GetCdcsObjectByType <CdcsSector>(cdcs_objects));
                        break;

                    case "CdcsServiceType":
                        context.CdcsServiceTypes.AddRange(GetCdcsObjectByType <CdcsServiceType>(cdcs_objects));
                        break;
                    }
                }
                nb_of_changes = context.SaveChanges();
            }

            return(nb_of_changes);
        }
 public AccreditorsController(CdcsContext context)
 {
     _context = context;
 }
예제 #5
0
 public AccreditorRepository(CdcsContext context) : base(context)
 {
 }
예제 #6
0
 public AppRepository(CdcsContext context)
 {
     _db    = context;
     _dbSet = _db.Set <TEntity>();
 }
예제 #7
0
 public AccreditationsController(CdcsContext context)
 {
     _context = context;
 }