示例#1
0
        public void GetAllCorporationInfoTest()
        {
            Mock <DbSet <SQLDatabase.EF.CorporationsView> > moq_CorpViews = new Mock <DbSet <SQLDatabase.EF.CorporationsView> >();

            moq_CorpViews.SetupData(cView);

            nuContext.Setup(c => c.CorporationsViews).Returns(moq_CorpViews.Object);
            AspnetDbHelpers ah = new AspnetDbHelpers(nuContext.Object);

            Assert.AreEqual(db.CorporationsViews.Count(), ah.GetAllCorporationInfo().Count);
        }
示例#2
0
        private static void UpdateVariables()
        {
            MigrationHistoryHelpers mig = new MigrationHistoryHelpers();
            var dh = mig.GetDatabaseHistories(currSiteId);

            AspnetDbHelpers ah   = new AspnetDbHelpers();
            var             corp = ah.GetAllCorporationInfo().FirstOrDefault(f => f.SiteId == currSiteId);

            Institution      = corp?.Site_Name;
            InitialMigration = (dh.Count == 0) ? "No Migration" : dh.OrderBy(o => o.LastMigrationDate).Select(s => s.LastMigrationDate.ToString()).First();
            LastMigration    = (dh.Count == 0) ? "No Migration" : dh.OrderBy(o => o.LastMigrationDate).Select(s => s.LastMigrationDate.ToString()).Last();
        }
        public void CreateInstitutionMapping()
        {
            try
            {
                var dataSet = aHelper.GetAllCorporationInfo();
                RecordCount = dataSet.Count;

                foreach (var ins in dataSet)
                {
                    var inst = new Institution
                    {
                        InstitutionId     = Guid.NewGuid(),
                        Name              = ins.Site_Name,
                        LegacySiteId      = (ins.SiteId.HasValue) ? ins.SiteId.Value : 0,
                        LastUpdatedByUser = Guid.Empty
                    };

                    MemoryMappings.AddInstitution(inst);

                    if (CanAddToContext(inst.Name, inst.LegacySiteId))
                    {
                        CompletedMappings.Add(inst);
                    }
                    else
                    {
                        MappingStatistics.LogFailedMapping("None", "None", "Institutions", typeof(Institution), JsonConvert.SerializeObject(inst), "Instition already exist in database.");
                        FailedCount++;
                    }
                }

                MappingStatistics.LogMappingStat("None", 0, "Institutions", CompletedMappings.Count, FailedCount);
            }
            catch (Exception e)
            {
                throw new Exception("Error creating Institution mapping.", e);
            }
        }