예제 #1
0
        private void CreateCountryGroups(int parentCategory, Dictionary <int, ForumCategory> items)
        {
            //var items = new List<ForumCategory>();

            var curId = parentCategory;

            var context   = new _8a_oldContext();
            var countries = context.Set <Model.ForumThreads>().Where(f => f.CountryCode != "GLOBAL" && f.ObjectClass == "CLS_ForumGeneral").Select(f => f.CountryCode).Distinct().ToList();

            foreach (var countryISO3 in countries)
            {
                var country = SeedStore.GetCountryByCountryISO3(countryISO3);
                if (country == null)
                {
                    Console.Write(Environment.NewLine);
                    Console.WriteLine("countrycode: '" + countryISO3 + "' not found. Skipped creating this country");
                    continue;
                }
                var now      = DateTime.Now;
                var newGroup = new ForumCategory
                {
                    Id           = ++curId,
                    Slug         = country.Slug,
                    Name         = country.Name,
                    UserId       = SeedStore.GetZeroUserId(),
                    DateCreated  = now,
                    DateModified = now,
                    ParentId     = parentCategory
                };
                items.Add(newGroup.Id.Value, newGroup);
            }

            //return items;
        }
예제 #2
0
        public string Generate(int maxRows, string staticFileName = "")
        {
            var context = new _8a_oldContext();
            IQueryable <_8anu.Data.Migration.Model.CragArea> oldAreas = context.Set <_8anu.Data.Migration.Model.CragArea>();

            if (maxRows > 0)
            {
                oldAreas = oldAreas.Take(maxRows);
            }

            newAreas = new List <Area>();
            foreach (var old in oldAreas)
            {
                var item = new Area
                {
                    Id           = old.Id,
                    Slug         = "",
                    Name         = old.Name,
                    Published    = true,
                    DateCreated  = old.Date,
                    DateModified = old.Date,
                    CountryId    = SeedStore.GetCountryByCountryISO3(old.CountryId).Id.Value,
                    LegacyId     = old.Id
                };

                newAreas.Add(item);
            }

            var json = JsonConvert.SerializeObject(newAreas);

            return(json);
        }