コード例 #1
0
        private static void PopulateParliamentHouse(JavnaRasprava.WEB.DomainModels.ApplicationDbContext context)
        {
            var stateParliament   = context.Parliaments.Where(x => x.Name == StringConstants.PARLIAMENT_NAME_STATE).FirstOrDefault();
            var federalParliament = context.Parliaments.Where(x => x.Name == StringConstants.PARLIAMENT_NAME_FEDERAL).FirstOrDefault();
            var rsParliament      = context.Parliaments.Where(x => x.Name == StringConstants.PARLIAMENT_NAME_RS).FirstOrDefault();

            var stateDomNaroda = new ParliamentHouse
            {
                Name         = StringConstants.HOUSE_NAME_STATE_UPPER,
                ParliamentID = stateParliament.ParliamentID
            };

            var statePredstavnicki = new ParliamentHouse
            {
                Name         = StringConstants.HOUSE_NAME_STATE_LOWER,
                ParliamentID = stateParliament.ParliamentID
            };

            var fbihDomNaroda = new ParliamentHouse
            {
                Name         = StringConstants.HOUSE_NAME_FBIH_UPPER,
                ParliamentID = federalParliament.ParliamentID
            };

            var fbihPredstavnicki = new ParliamentHouse
            {
                Name         = StringConstants.HOUSE_NAME_FBIH_LOWER,
                ParliamentID = federalParliament.ParliamentID
            };

            var rsDomNaroda = new ParliamentHouse
            {
                Name         = StringConstants.HOUSE_NAME_RS_UPPER,
                ParliamentID = rsParliament.ParliamentID
            };

            var rsPredstavnicki = new ParliamentHouse
            {
                Name         = StringConstants.HOUSE_NAME_RS_LOWER,
                ParliamentID = rsParliament.ParliamentID
            };

            context.ParliamentHouses.AddOrUpdate(ph => new { ph.ParliamentID, ph.Name },
                                                 stateDomNaroda,
                                                 statePredstavnicki,
                                                 fbihDomNaroda,
                                                 fbihPredstavnicki,
                                                 rsDomNaroda,
                                                 rsPredstavnicki);

            context.SaveChanges();
        }
コード例 #2
0
        private static void PopulateParliaments(JavnaRasprava.WEB.DomainModels.ApplicationDbContext context)
        {
            var stateParliament = new Parliament
            {
                Name = StringConstants.PARLIAMENT_NAME_STATE
            };
            var federalParliament = new Parliament
            {
                Name = StringConstants.PARLIAMENT_NAME_FEDERAL
            };
            var rsParliament = new Parliament
            {
                Name = StringConstants.PARLIAMENT_NAME_RS
            };

            context.Parliaments.AddOrUpdate(p => p.Name, stateParliament, federalParliament, rsParliament);

            context.SaveChanges();
        }