public void Import()
        {
            var users = new List<New.User>();

            Console.WriteLine("Grabbing users to get affiliates");
            using(var context = new New.RentlerEntities())
                users = context.Users.ToList();

            var oldaf = new List<Old.AffiliateUser>();
            using(var context = new Old.RentlerNewEntities())
                oldaf = context.AffiliateUsers.ToList();

            Console.WriteLine("Building reference map...");
            var dict = users.Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                .ToDictionary(x => x.Key, x => x.Value);

            Console.WriteLine("Building new Affiliates...");
            var newaf = new List<New.AffiliateUser>();
            foreach(var item in oldaf)
            {
                newaf.Add(new New.AffiliateUser
                {
                    AffiliateUserKey = item.AffiliateUserKey,
                    ApiKey = item.ApiKey,
                    IsDeleted = item.IsDeleted,
                    PasswordHash = item.PasswordHash,
                    UserId = dict[item.UserId]
                });
            }

            Console.WriteLine("Adding them to the new db...");

            using(var context = new New.RentlerEntities())
                context.BulkInsert(newaf);
        }
Example #2
0
        public void Import()
        {
            var oldPhotos = new List<Old.Photo>();

            List<long> buildingIds;
            using(var old = new Old.RentlerNewEntities())
                buildingIds = old.Buildings.Select(s => s.BuildingId).ToList();

            using(var old = new Old.RentlerNewEntities())
                oldPhotos = (from p in old.Photos
                             select p).ToList();

            using(var context = new New.RentlerEntities())
            {
                var newPhotos = new List<New.Photo>();

                foreach(var p in oldPhotos)
                    if(buildingIds.Contains(p.BuildingId))
                        newPhotos.Add(new New.Photo
                        {
                            BuildingId = p.BuildingId,
                            CreateDateUtc = p.CreateDate,
                            CreatedBy = p.CreatedBy,
                            Extension = p.Extension,
                            IsPrimary = p.IsPrimary,
                            PhotoId = p.PhotoId,
                            SortOrder = p.SortOrder,
                            UpdateDateUtc = p.UpdateDate.HasValue ? p.UpdateDate.Value : DateTime.UtcNow,
                            UpdatedBy = string.IsNullOrWhiteSpace(p.UpdatedBy) ? "linq script" : p.UpdatedBy
                        });

                Console.WriteLine("Adding photos...");
                context.BulkInsert(newPhotos, true);
            }
        }
Example #3
0
        public void Import()
        {
            var oldUsers = new List <Old.User>();

            Console.WriteLine("Getting old users...");
            using (var oldContext = new Old.RentlerNewEntities())
                oldUsers = oldContext.Users.ToList();

            var newUsers = new List <New.User>();

            Console.WriteLine("Converting them to the new stuff...");
            foreach (var item in oldUsers)
            {
                newUsers.Add(new New.User
                {
                    CreateDateUtc = item.CreateDate,
                    Email         = item.Email,
                    FirstName     = item.FirstName,
                    IsDeleted     = item.IsDeleted,
                    LastName      = item.LastName,
                    PasswordHash  = item.PasswordHash,
                    UpdateDateUtc = item.UpdateDate ?? item.CreateDate,
                    UpdatedBy     = item.UpdatedBy ?? "sql script",
                    ReferenceId   = item.UserId,
                    Username      = item.Username
                });
            }

            Console.WriteLine("Inserting {0} new users", newUsers.Count);

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newUsers);

            Console.WriteLine("Done with that noise! Woo.");
        }
Example #4
0
        public void Import()
        {
            var oldUsers = new List<Old.User>();

            Console.WriteLine("Getting old users...");
            using(var oldContext = new Old.RentlerNewEntities())
                oldUsers = oldContext.Users.ToList();

            var newUsers = new List<New.User>();

            Console.WriteLine("Converting them to the new stuff...");
            foreach(var item in oldUsers)
                newUsers.Add(new New.User
                {
                    CreateDateUtc = item.CreateDate,
                    Email = item.Email,
                    FirstName = item.FirstName,
                    IsDeleted = item.IsDeleted,
                    LastName = item.LastName,
                    PasswordHash = item.PasswordHash,
                    UpdateDateUtc = item.UpdateDate ?? item.CreateDate,
                    UpdatedBy = item.UpdatedBy ?? "sql script",
                    ReferenceId = item.UserId,
                    Username = item.Username
                });

            Console.WriteLine("Inserting {0} new users", newUsers.Count);

            using(var context = new New.RentlerEntities())
                context.BulkInsert(newUsers);

            Console.WriteLine("Done with that noise! Woo.");
        }
Example #5
0
        public void Import()
        {
            var newUsers = new List<New.User>();
            using (var context = new New.RentlerEntities())
                newUsers = context.Users.ToList();

            var usersKeyMap = new Dictionary<Guid, int>();
            using (var newContext = new New.RentlerEntities())
                usersKeyMap = newContext.Users
                    .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                    .ToDictionary(x => x.Key, y => y.Value);

            var oldOrders = new List<Old.Order>();
            using (var context = new Old.RentlerNewEntities())
                oldOrders = context.Orders.Include("OrderItems").Include("OrderItems.Product").ToList();

            var newOrders = new List<New.Order>();

            foreach (var item in oldOrders)
            {
                newOrders.Add(new New.Order
                {
                    CreateDate = item.PurchaseDate,
                    CreatedBy = "importer",
                    OrderId = (int)item.OrderId,
                    OrderStatusCode = New.OrderStatusCodeConverter.Convert(item.Status),
                    OrderTotal = item.OrderItems.Sum(o => o.Quantity * (o.ProductId == 2 ? 0.99m : 9.95m)),
                    UserCreditCardId = item.UserCreditCardId,
                    UserId = usersKeyMap[item.UserId]
                });
            }

            //save orders
            using (var context = new New.RentlerEntities())
                context.BulkInsert(newOrders, true);

            var newOrderItems = new List<New.OrderItem>();

            foreach (var item in oldOrders)
            {
                foreach (var o in item.OrderItems)
                {
                    newOrderItems.Add(new New.OrderItem
                    {
                        OrderId = (int)o.OrderId,
                        OrderItemId = (int)o.OrderItemId,
                        Price = o.Product.Price,
                        ProductId = New.ProductsConverter.Convert(o.ProductId),
                        ProductDescription = New.ProductsConverter.Convert(o.ProductId) + " imported",
                        ProductOption = New.ProductsConverter.Convert(o.ProductId) + " imported",
                        Quantity = 1
                    });
                }
            }

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newOrderItems, true);
        }
        public void Import()
        {
            var oldCards = new List <Old.UserCreditCard>();

            using (var context = new Old.RentlerNewEntities())
                oldCards = context.UserCreditCards.ToList();

            //get the new users; we need the old guid-based userid here
            //to bring the right relationship across.
            var newUsers = new List <New.User>();

            using (var context = new New.RentlerEntities())
                newUsers = context.Users.ToList();

            var usersKeyMap = new Dictionary <Guid, int>();

            using (var newContext = new New.RentlerEntities())
                usersKeyMap = newContext.Users
                              .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                              .ToDictionary(x => x.Key, y => y.Value);

            var newCards = new List <New.UserCreditCard>();

            foreach (var item in oldCards)
            {
                newCards.Add(new New.UserCreditCard
                {
                    AccountReference = item.AccountReference,
                    Address1         = item.AddressLine1,
                    Address2         = item.AddressLine2,
                    Alias            = item.Alias,
                    CardName         = item.CardName,
                    CardNumber       = item.CardNumber,
                    City             = item.City,
                    CreateDate       = item.CreateDate,
                    CreatedBy        = item.CreatedBy,
                    Email            = item.Email,
                    ExpirationMonth  = item.ExpirationMonth,
                    ExpirationYear   = item.ExpirationYear,
                    FirstName        = item.FirstName,
                    IsDeleted        = item.IsDeleted,
                    LastName         = item.LastName,
                    Phone            = item.Phone,
                    State            = item.State,
                    UpdateDate       = item.UpdateDate,
                    UpdatedBy        = item.UpdatedBy,
                    UserCreditCardId = item.UserCreditCardId,
                    UserId           = usersKeyMap[item.UserId],
                    Zip = item.Zip
                });
            }

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newCards, true);
        }
        public void Import()
        {
            var oldCards = new List<Old.UserCreditCard>();

            using (var context = new Old.RentlerNewEntities())
                oldCards = context.UserCreditCards.ToList();

            //get the new users; we need the old guid-based userid here
            //to bring the right relationship across.
            var newUsers = new List<New.User>();
            using (var context = new New.RentlerEntities())
                newUsers = context.Users.ToList();

            var usersKeyMap = new Dictionary<Guid, int>();
            using (var newContext = new New.RentlerEntities())
                usersKeyMap = newContext.Users
                    .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                    .ToDictionary(x => x.Key, y => y.Value);

            var newCards = new List<New.UserCreditCard>();

            foreach (var item in oldCards)
            {
                newCards.Add(new New.UserCreditCard
                {
                    AccountReference = item.AccountReference,
                    Address1 = item.AddressLine1,
                    Address2 = item.AddressLine2,
                    Alias = item.Alias,
                    CardName = item.CardName,
                    CardNumber = item.CardNumber,
                    City = item.City,
                    CreateDate = item.CreateDate,
                    CreatedBy = item.CreatedBy,
                    Email = item.Email,
                    ExpirationMonth = item.ExpirationMonth,
                    ExpirationYear = item.ExpirationYear,
                    FirstName = item.FirstName,
                    IsDeleted = item.IsDeleted,
                    LastName = item.LastName,
                    Phone = item.Phone,
                    State = item.State,
                    UpdateDate = item.UpdateDate,
                    UpdatedBy = item.UpdatedBy,
                    UserCreditCardId = item.UserCreditCardId,
                    UserId = usersKeyMap[item.UserId],
                    Zip = item.Zip
                });
            }

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newCards, true);
        }
        public void Import()
        {
            var oldFeatures = new List<Old.FeaturedListing>();
            using(var context = new Old.RentlerNewEntities())
                oldFeatures = context.FeaturedListings.Include("Building").ToList();

            //buildingid, scheduleddate, zip
            var newFeatures = new List<New.FeaturedListing>();
            foreach(var item in oldFeatures)
            {
                newFeatures.Add(new New.FeaturedListing
                {
                    BuildingId = item.BuildingId,
                    ScheduledDate = item.ScheduledDate,
                    Zip = item.Building.Zip
                });
            }

            using(var context = new New.RentlerEntities())
                context.BulkInsert(newFeatures);
        }
Example #9
0
        public void Import()
        {
            //get users for reference
            var newUsers = new Dictionary <Guid, int>();

            using (var newContext = new New.RentlerEntities())
                newUsers = newContext.Users
                           .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                           .ToDictionary(x => x.Key, y => y.Value);

            //grab the old contacts
            var oldContacts = new List <Old.ContactInfo>();

            using (var oldContext = new Old.RentlerNewEntities())
                oldContacts = oldContext.ContactInfos.ToList();

            //convert the old to the new
            var newContacts = new List <New.ContactInfo>();

            foreach (var item in oldContacts)
            {
                newContacts.Add(new New.ContactInfo
                {
                    CompanyName         = item.CompanyName,
                    ContactInfoId       = (int)item.ContactInfoId,
                    Email               = item.Email,
                    ContactInfoTypeCode = (int)New.ContactInfoTypeConverter.Convert(item.Type),
                    Name             = item.Name,
                    PhoneNumber      = item.PhoneNumber,
                    ShowEmailAddress = true,
                    ShowPhoneNumber  = item.DisplayPhoneNumber,
                    UserId           = newUsers[item.UserId]
                });
            }

            //commit them to the new db, enabling identity_insert
            //for a moment so we can keep the same ids.
            using (var context = new New.RentlerEntities())
                context.BulkInsert(newContacts, true);
        }
        public void Import()
        {
            //get the new users; we need the old guid-based userid here
            //to bring the right relationship across.
            var newUsers = new List <New.User>();

            using (var context = new New.RentlerEntities())
                newUsers = context.Users.ToList();

            var usersKeyMap = new Dictionary <Guid, int>();

            using (var newContext = new New.RentlerEntities())
                usersKeyMap = newContext.Users
                              .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                              .ToDictionary(x => x.Key, y => y.Value);

            //get the old saved buildings
            var oldSaves = new List <Old.SavedBuilding>();

            using (var context = new Old.RentlerNewEntities())
                oldSaves = context.SavedBuildings.ToList();

            //create new saved buildings, using the new int based userId
            var newSaves = new List <New.SavedBuilding>();

            foreach (var item in oldSaves)
            {
                newSaves.Add(new New.SavedBuilding
                {
                    BuildingId    = item.BuildingId,
                    CreateDateUtc = item.CreateDate,
                    CreatedBy     = item.CreatedBy,
                    UserId        = usersKeyMap[item.UserId]
                });
            }

            //finally, add them to the db.
            using (var context = new New.RentlerEntities())
                context.BulkInsert(newSaves);
        }
Example #11
0
        public void Import()
        {
            var oldPhotos = new List <Old.Photo>();

            List <long> buildingIds;

            using (var old = new Old.RentlerNewEntities())
                buildingIds = old.Buildings.Select(s => s.BuildingId).ToList();

            using (var old = new Old.RentlerNewEntities())
                oldPhotos = (from p in old.Photos
                             select p).ToList();

            using (var context = new New.RentlerEntities())
            {
                var newPhotos = new List <New.Photo>();

                foreach (var p in oldPhotos)
                {
                    if (buildingIds.Contains(p.BuildingId))
                    {
                        newPhotos.Add(new New.Photo
                        {
                            BuildingId    = p.BuildingId,
                            CreateDateUtc = p.CreateDate,
                            CreatedBy     = p.CreatedBy,
                            Extension     = p.Extension,
                            IsPrimary     = p.IsPrimary,
                            PhotoId       = p.PhotoId,
                            SortOrder     = p.SortOrder,
                            UpdateDateUtc = p.UpdateDate.HasValue ? p.UpdateDate.Value : DateTime.UtcNow,
                            UpdatedBy     = string.IsNullOrWhiteSpace(p.UpdatedBy) ? "linq script" : p.UpdatedBy
                        });
                    }
                }

                Console.WriteLine("Adding photos...");
                context.BulkInsert(newPhotos, true);
            }
        }
        public void Import()
        {
            //get the new users; we need the old guid-based userid here
            //to bring the right relationship across.
            var newUsers = new List <New.User>();

            using (var context = new New.RentlerEntities())
                newUsers = context.Users.ToList();

            var usersKeyMap = new Dictionary <Guid, int>();

            using (var newContext = new New.RentlerEntities())
                usersKeyMap = newContext.Users
                              .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                              .ToDictionary(x => x.Key, y => y.Value);

            var oldInterests = new List <Old.UserInterest>();

            using (var context = new Old.RentlerNewEntities())
                oldInterests = context.UserInterests.ToList();

            var newInterests = new List <New.UserInterest>();

            foreach (var item in oldInterests)
            {
                newInterests.Add(new New.UserInterest
                {
                    BuildingId           = item.BuildingId,
                    Message              = item.Message,
                    ResponseMessage      = item.ResponseMessage,
                    UserId               = usersKeyMap[item.UserId],
                    UserInterestId       = item.UserInterestId,
                    ApplicationSubmitted = item.ShowApplicationInfo
                });
            }

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newInterests, true);
        }
Example #13
0
        public void Import()
        {
            Console.WriteLine("Getting api keys...");
            var oldKeys = new List<Old.ApiKey>();
            using(var context = new Old.RentlerNewEntities())
                oldKeys = context.ApiKeys.ToList();

            var newKeys = new List<New.ApiKey>();

            Console.WriteLine("Making new ones...");
            foreach(var item in oldKeys)
            {
                newKeys.Add(new New.ApiKey
                {
                    ApiKeyId = item.ApiKeyId,
                    Name = item.Name
                });
            }

            Console.WriteLine("Adding them to the new stuff!");
            using(var context = new New.RentlerEntities())
                context.BulkInsert(newKeys);
        }
        public void Import()
        {
            var oldFeatures = new List <Old.FeaturedListing>();

            using (var context = new Old.RentlerNewEntities())
                oldFeatures = context.FeaturedListings.Include("Building").ToList();

            //buildingid, scheduleddate, zip
            var newFeatures = new List <New.FeaturedListing>();

            foreach (var item in oldFeatures)
            {
                newFeatures.Add(new New.FeaturedListing
                {
                    BuildingId    = item.BuildingId,
                    ScheduledDate = item.ScheduledDate,
                    Zip           = item.Building.Zip
                });
            }

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newFeatures);
        }
        public void Import()
        {
            //get the new users; we need the old guid-based userid here
            //to bring the right relationship across.
            var newUsers = new List<New.User>();
            using (var context = new New.RentlerEntities())
                newUsers = context.Users.ToList();

            var usersKeyMap = new Dictionary<Guid, int>();
            using (var newContext = new New.RentlerEntities())
                usersKeyMap = newContext.Users
                    .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                    .ToDictionary(x => x.Key, y => y.Value);

            var oldInterests = new List<Old.UserInterest>();

            using (var context = new Old.RentlerNewEntities())
                oldInterests = context.UserInterests.ToList();

            var newInterests = new List<New.UserInterest>();

            foreach (var item in oldInterests)
            {
                newInterests.Add(new New.UserInterest
                {
                    BuildingId = item.BuildingId,
                    Message = item.Message,
                    ResponseMessage = item.ResponseMessage,
                    UserId = usersKeyMap[item.UserId],
                    UserInterestId = item.UserInterestId,
                    ApplicationSubmitted = item.ShowApplicationInfo
                });
            }

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newInterests, true);
        }
Example #16
0
        public void Import()
        {
            var users = new List <New.User>();

            Console.WriteLine("Grabbing users to get affiliates");
            using (var context = new New.RentlerEntities())
                users = context.Users.ToList();

            var oldaf = new List <Old.AffiliateUser>();

            using (var context = new Old.RentlerNewEntities())
                oldaf = context.AffiliateUsers.ToList();

            Console.WriteLine("Building reference map...");
            var dict = users.Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                       .ToDictionary(x => x.Key, x => x.Value);

            Console.WriteLine("Building new Affiliates...");
            var newaf = new List <New.AffiliateUser>();

            foreach (var item in oldaf)
            {
                newaf.Add(new New.AffiliateUser
                {
                    AffiliateUserKey = item.AffiliateUserKey,
                    ApiKey           = item.ApiKey,
                    IsDeleted        = item.IsDeleted,
                    PasswordHash     = item.PasswordHash,
                    UserId           = dict[item.UserId]
                });
            }

            Console.WriteLine("Adding them to the new db...");

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newaf);
        }
        public void Import()
        {
            //get users for reference
            var newUsers = new Dictionary<Guid, int>();
            using(var newContext = new New.RentlerEntities())
                newUsers = newContext.Users
                    .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                    .ToDictionary(x => x.Key, y => y.Value);

            //grab the old contacts
            var oldContacts = new List<Old.ContactInfo>();
            using(var oldContext = new Old.RentlerNewEntities())
                oldContacts = oldContext.ContactInfos.ToList();

            //convert the old to the new
            var newContacts = new List<New.ContactInfo>();
            foreach(var item in oldContacts)
            {
                newContacts.Add(new New.ContactInfo
                {
                    CompanyName = item.CompanyName,
                    ContactInfoId = (int)item.ContactInfoId,
                    Email = item.Email,
                    ContactInfoTypeCode = (int)New.ContactInfoTypeConverter.Convert(item.Type),
                    Name = item.Name,
                    PhoneNumber = item.PhoneNumber,
                    ShowEmailAddress = true,
                    ShowPhoneNumber = item.DisplayPhoneNumber,
                    UserId = newUsers[item.UserId]
                });
            }

            //commit them to the new db, enabling identity_insert
            //for a moment so we can keep the same ids.
            using(var context = new New.RentlerEntities())
                context.BulkInsert(newContacts, true);
        }
Example #18
0
        public void Import()
        {
            Console.WriteLine("Getting api keys...");
            var oldKeys = new List <Old.ApiKey>();

            using (var context = new Old.RentlerNewEntities())
                oldKeys = context.ApiKeys.ToList();

            var newKeys = new List <New.ApiKey>();

            Console.WriteLine("Making new ones...");
            foreach (var item in oldKeys)
            {
                newKeys.Add(new New.ApiKey
                {
                    ApiKeyId = item.ApiKeyId,
                    Name     = item.Name
                });
            }

            Console.WriteLine("Adding them to the new stuff!");
            using (var context = new New.RentlerEntities())
                context.BulkInsert(newKeys);
        }
        public void Import()
        {
            //get the new users; we need the old guid-based userid here
            //to bring the right relationship across.
            var newUsers = new List<New.User>();
            using(var context = new New.RentlerEntities())
                newUsers = context.Users.ToList();

            var usersKeyMap = new Dictionary<Guid, int>();
            using(var newContext = new New.RentlerEntities())
                usersKeyMap = newContext.Users
                    .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                    .ToDictionary(x => x.Key, y => y.Value);

            //get the old saved buildings
            var oldSaves = new List<Old.SavedBuilding>();
            using(var context = new Old.RentlerNewEntities())
                oldSaves = context.SavedBuildings.ToList();

            //create new saved buildings, using the new int based userId
            var newSaves = new List<New.SavedBuilding>();
            foreach(var item in oldSaves)
            {
                newSaves.Add(new New.SavedBuilding
                {
                    BuildingId = item.BuildingId,
                    CreateDateUtc = item.CreateDate,
                    CreatedBy = item.CreatedBy,
                    UserId = usersKeyMap[item.UserId]
                });
            }

            //finally, add them to the db.
            using(var context = new New.RentlerEntities())
                context.BulkInsert(newSaves);
        }
        public void Import()
        {
            var oldBuildings = new List<Old.Building>();

            Console.WriteLine("Getting old buildings...");
            using(var old = new Old.RentlerNewEntities())
                oldBuildings = old.Buildings.ToList();

            var newUsers = new Dictionary<Guid, int>();
            using(var newContext = new New.RentlerEntities())
                newUsers = newContext.Users
                    .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                    .ToDictionary(x => x.Key, y => y.Value);

            Console.WriteLine("Building ribbons map...");

            var oldRibbons = new List<Old.Ribbon>();
            using(var old = new Old.RentlerNewEntities())
                oldRibbons = old.Ribbons.ToList();

            var newRibbons = new Dictionary<string, string>();
            newRibbons.Add("3cargarage", "3 Car Garage");
            newRibbons.Add("bigyard", "Big Yard");
            newRibbons.Add("brandnew", "Brand New");
            newRibbons.Add("greatschools", "Great Schools");
            newRibbons.Add("nearapark", "Near a Park");
            newRibbons.Add("noyardwork", "No Yardwork");
            newRibbons.Add("petfriendly", "Pet Friendly");
            newRibbons.Add("snowremoval", "Snow Removal");
            newRibbons.Add("utilitiesincluded", "Utilities Included");
            newRibbons.Add("newlyremodeled", "Newly Remodeled");
            newRibbons.Add("airconditioning", "Air Conditioning");
            newRibbons.Add("clubhouse", "Clubhouse");
            newRibbons.Add("fencedyard", "Fenced Yard");
            newRibbons.Add("firstmonthfree", "First Month Free");
            newRibbons.Add("fitnesscenter", "Fitness Center");
            newRibbons.Add("granitecountertops", "Granite Countertops");
            newRibbons.Add("hardwoodfloors", "Hardwood Floors");
            newRibbons.Add("hottub", "Hot Tub");
            newRibbons.Add("monthtomonth", "Month to Month");
            newRibbons.Add("newcarpet", "New Carpet");
            newRibbons.Add("newpaint", "New Paint");
            newRibbons.Add("onsitemaintenance", "Onsite Maintenance");
            newRibbons.Add("onsitemanager", "Onsite Manager");
            newRibbons.Add("playground", "Playground");
            newRibbons.Add("pool", "Pool");
            newRibbons.Add("smokerfriendly", "Smoker Friendly");
            newRibbons.Add("stainlessappliances", "Stainless Appliances");
            newRibbons.Add("washerdryer", "Washer/Dryer");
            newRibbons = newRibbons.ToDictionary(x => x.Value, y => y.Key);

            var map = new Dictionary<int, string>();
            foreach(var item in oldRibbons)
                map.Add(item.RibbonId, newRibbons[item.Name]);

            Console.WriteLine("Got old buildings, moving them into the new one.");

            using(var context = new New.RentlerEntities())
            {
                var buildings = new List<New.Building>();
                foreach(var item in oldBuildings)
                {
                    var b = new New.Building();
                    b.Acres = (float)item.Acres;
                    b.Address1 = item.Address1;
                    b.Address2 = item.Address2;
                    b.ArePetsAllowed = item.PetsAllowed.HasValue ? item.PetsAllowed.Value : false;
                    b.Bathrooms = (float)item.Bathrooms;
                    b.Bedrooms = item.Bedrooms > 0 ? item.Bedrooms : 1;
                    b.BuildingId = item.BuildingId;
                    b.City = item.City;
                    b.PropertyTypeCode = (int)New.PropertyInfoConverter.Convert(item.PropertyType);
                    b.CreateDateUtc = item.CreateDate;
                    b.CreatedBy = item.CreatedBy;
                    b.DateActivatedUtc = item.DateActivated;
                    b.DateAvailableUtc = item.DateAvailable;
                    b.Deposit = item.Deposit.HasValue ? item.Deposit.Value : 0;
                    b.Description = item.Description;
                    b.IsActive = item.IsActive;
                    b.IsBackgroundCheckRequired = item.BackgroundCheckRequired;
                    b.IsCreditCheckRequired = item.CreditCheckRequired;
                    b.IsDeleted = item.IsDeleted;
                    b.IsRemovedByAdmin = item.RemovedByAdmin;
                    b.IsSmokingAllowed = item.SmokingAllowed;
                    b.Latitude = string.IsNullOrWhiteSpace(item.Latitude) ? 0 : float.Parse(item.Latitude);
                    b.Longitude = string.IsNullOrWhiteSpace(item.Longitude) ? 0 : float.Parse(item.Longitude);
                    b.LeaseLengthCode = (int)New.LeaseLengthConverter.Convert(item.LeaseLength);
                    b.PetFee = item.PetFee.HasValue ? item.PetFee.Value : 0;
                    b.Price = item.Price.HasValue ? item.Price.Value : 0;
                    b.RefundableDeposit = item.RefundableDeposit.HasValue ? item.Price.Value : 0;
                    b.SquareFeet = item.SquareFeet > 0 ? item.SquareFeet : 1;
                    b.State = item.State;
                    b.Title = item.Title;
                    b.UpdateDateUtc = item.UpdateDate.HasValue ? item.UpdateDate.Value : DateTime.UtcNow;
                    b.UpdatedBy = string.IsNullOrWhiteSpace(item.UpdatedBy) ? "dusda" : item.UpdatedBy;
                    b.UserId = newUsers[item.UserId];
                    b.YearBuilt = item.YearBuilt;
                    b.Zip = item.Zip;
                    b.ContactInfoId = (int)item.ContactInfoId;
                    b.RibbonId = item.RibbonId.HasValue ? map[item.RibbonId.Value] : null;
                    b.PrimaryPhotoId = item.PrimaryPhotoId;
                    b.PrimaryPhotoExtension = item.PrimaryPhotoExtension;
                    b.HasPriority = false;
                    buildings.Add(b);
                }
                context.BulkInsert(buildings, true);
            }

            Console.WriteLine("Awesome, on to photos...");
            oldBuildings.Clear();
        }
Example #21
0
        public void Import()
        {
            var newUsers = new List <New.User>();

            using (var context = new New.RentlerEntities())
                newUsers = context.Users.ToList();

            var usersKeyMap = new Dictionary <Guid, int>();

            using (var newContext = new New.RentlerEntities())
                usersKeyMap = newContext.Users
                              .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                              .ToDictionary(x => x.Key, y => y.Value);


            var oldOrders = new List <Old.Order>();

            using (var context = new Old.RentlerNewEntities())
                oldOrders = context.Orders.Include("OrderItems").Include("OrderItems.Product").ToList();

            var newOrders = new List <New.Order>();

            foreach (var item in oldOrders)
            {
                newOrders.Add(new New.Order
                {
                    CreateDate       = item.PurchaseDate,
                    CreatedBy        = "importer",
                    OrderId          = (int)item.OrderId,
                    OrderStatusCode  = New.OrderStatusCodeConverter.Convert(item.Status),
                    OrderTotal       = item.OrderItems.Sum(o => o.Quantity * (o.ProductId == 2 ? 0.99m : 9.95m)),
                    UserCreditCardId = item.UserCreditCardId,
                    UserId           = usersKeyMap[item.UserId]
                });
            }

            //save orders
            using (var context = new New.RentlerEntities())
                context.BulkInsert(newOrders, true);

            var newOrderItems = new List <New.OrderItem>();

            foreach (var item in oldOrders)
            {
                foreach (var o in item.OrderItems)
                {
                    newOrderItems.Add(new New.OrderItem
                    {
                        OrderId            = (int)o.OrderId,
                        OrderItemId        = (int)o.OrderItemId,
                        Price              = o.Product.Price,
                        ProductId          = New.ProductsConverter.Convert(o.ProductId),
                        ProductDescription = New.ProductsConverter.Convert(o.ProductId) + " imported",
                        ProductOption      = New.ProductsConverter.Convert(o.ProductId) + " imported",
                        Quantity           = 1
                    });
                }
            }

            using (var context = new New.RentlerEntities())
                context.BulkInsert(newOrderItems, true);
        }
Example #22
0
        public void Import()
        {
            var oldBuildings = new List <Old.Building>();

            Console.WriteLine("Getting old buildings...");
            using (var old = new Old.RentlerNewEntities())
                oldBuildings = old.Buildings.ToList();

            var newUsers = new Dictionary <Guid, int>();

            using (var newContext = new New.RentlerEntities())
                newUsers = newContext.Users
                           .Select(u => new { Key = u.ReferenceId, Value = u.UserId })
                           .ToDictionary(x => x.Key, y => y.Value);

            Console.WriteLine("Building ribbons map...");

            var oldRibbons = new List <Old.Ribbon>();

            using (var old = new Old.RentlerNewEntities())
                oldRibbons = old.Ribbons.ToList();

            var newRibbons = new Dictionary <string, string>();

            newRibbons.Add("3cargarage", "3 Car Garage");
            newRibbons.Add("bigyard", "Big Yard");
            newRibbons.Add("brandnew", "Brand New");
            newRibbons.Add("greatschools", "Great Schools");
            newRibbons.Add("nearapark", "Near a Park");
            newRibbons.Add("noyardwork", "No Yardwork");
            newRibbons.Add("petfriendly", "Pet Friendly");
            newRibbons.Add("snowremoval", "Snow Removal");
            newRibbons.Add("utilitiesincluded", "Utilities Included");
            newRibbons.Add("newlyremodeled", "Newly Remodeled");
            newRibbons.Add("airconditioning", "Air Conditioning");
            newRibbons.Add("clubhouse", "Clubhouse");
            newRibbons.Add("fencedyard", "Fenced Yard");
            newRibbons.Add("firstmonthfree", "First Month Free");
            newRibbons.Add("fitnesscenter", "Fitness Center");
            newRibbons.Add("granitecountertops", "Granite Countertops");
            newRibbons.Add("hardwoodfloors", "Hardwood Floors");
            newRibbons.Add("hottub", "Hot Tub");
            newRibbons.Add("monthtomonth", "Month to Month");
            newRibbons.Add("newcarpet", "New Carpet");
            newRibbons.Add("newpaint", "New Paint");
            newRibbons.Add("onsitemaintenance", "Onsite Maintenance");
            newRibbons.Add("onsitemanager", "Onsite Manager");
            newRibbons.Add("playground", "Playground");
            newRibbons.Add("pool", "Pool");
            newRibbons.Add("smokerfriendly", "Smoker Friendly");
            newRibbons.Add("stainlessappliances", "Stainless Appliances");
            newRibbons.Add("washerdryer", "Washer/Dryer");
            newRibbons = newRibbons.ToDictionary(x => x.Value, y => y.Key);

            var map = new Dictionary <int, string>();

            foreach (var item in oldRibbons)
            {
                map.Add(item.RibbonId, newRibbons[item.Name]);
            }

            Console.WriteLine("Got old buildings, moving them into the new one.");

            using (var context = new New.RentlerEntities())
            {
                var buildings = new List <New.Building>();
                foreach (var item in oldBuildings)
                {
                    var b = new New.Building();
                    b.Acres                     = (float)item.Acres;
                    b.Address1                  = item.Address1;
                    b.Address2                  = item.Address2;
                    b.ArePetsAllowed            = item.PetsAllowed.HasValue ? item.PetsAllowed.Value : false;
                    b.Bathrooms                 = (float)item.Bathrooms;
                    b.Bedrooms                  = item.Bedrooms > 0 ? item.Bedrooms : 1;
                    b.BuildingId                = item.BuildingId;
                    b.City                      = item.City;
                    b.PropertyTypeCode          = (int)New.PropertyInfoConverter.Convert(item.PropertyType);
                    b.CreateDateUtc             = item.CreateDate;
                    b.CreatedBy                 = item.CreatedBy;
                    b.DateActivatedUtc          = item.DateActivated;
                    b.DateAvailableUtc          = item.DateAvailable;
                    b.Deposit                   = item.Deposit.HasValue ? item.Deposit.Value : 0;
                    b.Description               = item.Description;
                    b.IsActive                  = item.IsActive;
                    b.IsBackgroundCheckRequired = item.BackgroundCheckRequired;
                    b.IsCreditCheckRequired     = item.CreditCheckRequired;
                    b.IsDeleted                 = item.IsDeleted;
                    b.IsRemovedByAdmin          = item.RemovedByAdmin;
                    b.IsSmokingAllowed          = item.SmokingAllowed;
                    b.Latitude                  = string.IsNullOrWhiteSpace(item.Latitude) ? 0 : float.Parse(item.Latitude);
                    b.Longitude                 = string.IsNullOrWhiteSpace(item.Longitude) ? 0 : float.Parse(item.Longitude);
                    b.LeaseLengthCode           = (int)New.LeaseLengthConverter.Convert(item.LeaseLength);
                    b.PetFee                    = item.PetFee.HasValue ? item.PetFee.Value : 0;
                    b.Price                     = item.Price.HasValue ? item.Price.Value : 0;
                    b.RefundableDeposit         = item.RefundableDeposit.HasValue ? item.Price.Value : 0;
                    b.SquareFeet                = item.SquareFeet > 0 ? item.SquareFeet : 1;
                    b.State                     = item.State;
                    b.Title                     = item.Title;
                    b.UpdateDateUtc             = item.UpdateDate.HasValue ? item.UpdateDate.Value : DateTime.UtcNow;
                    b.UpdatedBy                 = string.IsNullOrWhiteSpace(item.UpdatedBy) ? "dusda" : item.UpdatedBy;
                    b.UserId                    = newUsers[item.UserId];
                    b.YearBuilt                 = item.YearBuilt;
                    b.Zip                   = item.Zip;
                    b.ContactInfoId         = (int)item.ContactInfoId;
                    b.RibbonId              = item.RibbonId.HasValue ? map[item.RibbonId.Value] : null;
                    b.PrimaryPhotoId        = item.PrimaryPhotoId;
                    b.PrimaryPhotoExtension = item.PrimaryPhotoExtension;
                    b.HasPriority           = false;
                    buildings.Add(b);
                }
                context.BulkInsert(buildings, true);
            }

            Console.WriteLine("Awesome, on to photos...");
            oldBuildings.Clear();
        }
Example #23
0
        public void Import()
        {
            //This one does all of the amenities stuff

            var current = New.Amenities.Current;

            /*
             * amenityid	name	category
             * 3	Cable/Satellite	Property
             * 4	Dishwasher	Property
             * 6	Washer/Dryer	Property
             * 7	Pool	Community
             * 8	Hot Tub	Community
             * 10	Carpet	Property
             * 11	Fireplace	Property
             * 12	High Ceilings	Property
             * 13	Microwave	Property
             * 14	Patio/Balcony	Property
             * 16	View	Property
             * 17	Hardwood Floors	Property
             * 24	Newly Remodeled	Property
             * 25	Fenced Yard	Property
             * 26	Washer/Dryer hookups	Property
             * 27	New Paint	Property
             * 28	New Carpet	Property
             * 29	Granite Countertops	Property
             * 30	Walk-In Closets	Property
             * 31	Tile	Property
             * 32	Storage	Property
             * 33	Pet-Friendly	Property
             */

            //property amenities map (for old amenities with type Property)
            var propMapBase = new Dictionary <string, int>();

            propMapBase["washerdryer"]        = 6;
            propMapBase["washerdryerhookups"] = 26;
            propMapBase["dishwasher"]         = 4;
            //internetready
            //handicapaccessible

            propMapBase["hardwood"]      = 17;
            propMapBase["tile"]          = 31;
            propMapBase["walkinclosets"] = 30;
            propMapBase["fireplace"]     = 11;
            //alarm

            //upgraded countertops
            //propMapBase["highceilings"] = 12;
            propMapBase["upgradedcountertops"] = 29;
            propMapBase["remodeled"]           = 24;
            propMapBase["newpaint"]            = 27;
            propMapBase["newcarpet"]           = 28;
            propMapBase["storage"]             = 32;

            //pool
            //hot tub
            propMapBase["microwave"] = 13;
            //propMapBase["patiobalcony"] = 14;
            //deck
            propMapBase["view"]       = 16;
            propMapBase["fencedyard"] = 25;

            //invert it cause I feel like it, and I don't feel like re-writing the above.
            //its kinda useless the other way.
            var propMap = propMapBase.ToDictionary(x => x.Value, x => x.Key);

            //community amenities map (for old amenities with type Community)
            var comMap = new Dictionary <int, string>();

            comMap[7] = "communitypool";
            comMap[8] = "communityhottub";

            //community options
            var coMap = new Dictionary <int, Dictionary <string, string> >();

            coMap[1] = new Dictionary <string, string>
            {
                { "1 Car", "coveredparking" },
                { "2 Cars", "coveredparking2cars" },
                { "3+ Cars", "coveredparking3+cars" }
            };
            coMap[2] = new Dictionary <string, string>
            {
                { "1 Car", "streetparking1car" },
                { "2 Cars", "streetparking2cars" },
                { "3+ Cars", "streetparking3+cars" }
            };

            //property options
            var poMap = new Dictionary <int, Dictionary <string, string> >();

            poMap[3] = new Dictionary <string, string>
            {
                { "Central Air", "centralair" },
                { "Evaporative Cooler", "evaporativecooler" },
                { "Window Unit", "windowunit" },
                { "Other", "other" }
            };

            //I'MA CHARGIN MA CONVERSION


            //do basic amenities
            List <Old.BuildingAmenity> basicProperty = new List <Old.BuildingAmenity>();

            using (var context = new Old.RentlerNewEntities())
                basicProperty = context.BuildingAmenities
                                .Where(p => p.Amenity.Category == "Property").ToList();

            //put them in that db!
            using (var context = new New.RentlerEntities())
            {
                var ba = new List <New.BuildingAmenity>();
                foreach (var item in basicProperty)
                {
                    if (propMap.ContainsKey(item.AmenityId))
                    {
                        ba.Add(new New.BuildingAmenity
                        {
                            BuildingId = item.BuildingId,
                            AmenityId  = propMap[item.AmenityId]
                        });
                    }
                }

                Console.WriteLine("Prepped {0} amenities, inserting!", ba.Count);

                context.BulkInsert(ba);

                basicProperty.Clear();
            }


            //time for community basics!
            List <Old.BuildingAmenity> basicCommunity = new List <Old.BuildingAmenity>();

            using (var context = new Old.RentlerNewEntities())
                basicCommunity = context.BuildingAmenities
                                 .Where(b => b.Amenity.Category == "Community").ToList();

            //get them in there!
            using (var context = new New.RentlerEntities())
            {
                var ca = new List <New.BuildingAmenity>();
                foreach (var item in basicCommunity)
                {
                    ca.Add(new New.BuildingAmenity
                    {
                        BuildingId = item.BuildingId,
                        AmenityId  = comMap[item.AmenityId]
                    });
                }

                Console.WriteLine("Prepped {0} community amenities, inserting!", ca.Count);

                context.BulkInsert(ca);

                basicCommunity.Clear();
            }


            //and on to property options
            var propOptions = new List <Old.BuildingAmenitiesWithOption>();

            using (var context = new Old.RentlerNewEntities())
                propOptions = context.BuildingAmenitiesWithOptions
                              .Where(b => b.AmenityId != 4 &&
                                     b.AmenitiesWithOption.Category == "Property" &&
                                     b.Option != "Forced Air").ToList();

            //convert those beasts
            var pwo = new List <New.BuildingAmenity>();

            foreach (var item in propOptions)
            {
                pwo.Add(new New.BuildingAmenity
                {
                    BuildingId = item.BuildingId,
                    AmenityId  = poMap[item.AmenityId][item.Option]
                });
            }

            using (var context = new New.RentlerEntities())
            {
                context.BulkInsert(pwo);

                propOptions.Clear();
                pwo.Clear();
            }


            //finally, community options
            var comOptions = new List <Old.BuildingAmenitiesWithOption>();

            using (var context = new Old.RentlerNewEntities())
                comOptions = context.BuildingAmenitiesWithOptions
                             .Where(b => b.AmenitiesWithOption.Category == "Community").ToList();

            //convert 'em!
            var cwo = new List <New.BuildingAmenity>();

            foreach (var item in comOptions)
            {
                cwo.Add(new New.BuildingAmenity
                {
                    BuildingId = item.BuildingId,
                    AmenityId  = coMap[item.AmenityId][item.Option]
                });
            }

            using (var context = new New.RentlerEntities())
            {
                context.BulkInsert(cwo);

                comOptions.Clear();
                cwo.Clear();
            }

            Console.WriteLine("Done!");
        }
        public void Import()
        {
            //This one does all of the amenities stuff

            var current = New.Amenities.Current;

            /*
            amenityid	name	category
            3	Cable/Satellite	Property
            4	Dishwasher	Property
            6	Washer/Dryer	Property
            7	Pool	Community
            8	Hot Tub	Community
            10	Carpet	Property
            11	Fireplace	Property
            12	High Ceilings	Property
            13	Microwave	Property
            14	Patio/Balcony	Property
            16	View	Property
            17	Hardwood Floors	Property
            24	Newly Remodeled	Property
            25	Fenced Yard	Property
            26	Washer/Dryer hookups	Property
            27	New Paint	Property
            28	New Carpet	Property
            29	Granite Countertops	Property
            30	Walk-In Closets	Property
            31	Tile	Property
            32	Storage	Property
            33	Pet-Friendly	Property
             */

            //property amenities map (for old amenities with type Property)
            var propMapBase = new Dictionary<string, int>();
            propMapBase["washerdryer"] = 6;
            propMapBase["washerdryerhookups"] = 26;
            propMapBase["dishwasher"] = 4;
            //internetready
            //handicapaccessible

            propMapBase["hardwood"] = 17;
            propMapBase["tile"] = 31;
            propMapBase["walkinclosets"] = 30;
            propMapBase["fireplace"] = 11;
            //alarm

            //upgraded countertops
            //propMapBase["highceilings"] = 12;
            propMapBase["upgradedcountertops"] = 29;
            propMapBase["remodeled"] = 24;
            propMapBase["newpaint"] = 27;
            propMapBase["newcarpet"] = 28;
            propMapBase["storage"] = 32;

            //pool
            //hot tub
            propMapBase["microwave"] = 13;
            //propMapBase["patiobalcony"] = 14;
            //deck
            propMapBase["view"] = 16;
            propMapBase["fencedyard"] = 25;

            //invert it cause I feel like it, and I don't feel like re-writing the above.
            //its kinda useless the other way.
            var propMap = propMapBase.ToDictionary(x => x.Value, x => x.Key);

            //community amenities map (for old amenities with type Community)
            var comMap = new Dictionary<int, string>();
            comMap[7] = "communitypool";
            comMap[8] = "communityhottub";

            //community options
            var coMap = new Dictionary<int, Dictionary<string, string>>();
            coMap[1] = new Dictionary<string, string>
            {
                {"1 Car", "coveredparking"},
                {"2 Cars", "coveredparking2cars"},
                {"3+ Cars", "coveredparking3+cars"}
            };
            coMap[2] = new Dictionary<string, string>
            {
                {"1 Car", "streetparking1car"},
                {"2 Cars", "streetparking2cars"},
                {"3+ Cars", "streetparking3+cars"}
            };

            //property options
            var poMap = new Dictionary<int, Dictionary<string, string>>();
            poMap[3] = new Dictionary<string, string>
            {
                {"Central Air", "centralair"},
                {"Evaporative Cooler","evaporativecooler"},
                {"Window Unit", "windowunit"},
                {"Other", "other"}
            };

            //I'MA CHARGIN MA CONVERSION

            //do basic amenities
            List<Old.BuildingAmenity> basicProperty = new List<Old.BuildingAmenity>();
            using(var context = new Old.RentlerNewEntities())
                basicProperty = context.BuildingAmenities
                    .Where(p => p.Amenity.Category == "Property").ToList();

            //put them in that db!
            using(var context = new New.RentlerEntities())
            {
                var ba = new List<New.BuildingAmenity>();
                foreach(var item in basicProperty)
                {
                    if(propMap.ContainsKey(item.AmenityId))
                        ba.Add(new New.BuildingAmenity
                        {
                            BuildingId = item.BuildingId,
                            AmenityId = propMap[item.AmenityId]
                        });
                }

                Console.WriteLine("Prepped {0} amenities, inserting!", ba.Count);

                context.BulkInsert(ba);

                basicProperty.Clear();
            }

            //time for community basics!
            List<Old.BuildingAmenity> basicCommunity = new List<Old.BuildingAmenity>();
            using(var context = new Old.RentlerNewEntities())
                basicCommunity = context.BuildingAmenities
                    .Where(b => b.Amenity.Category == "Community").ToList();

            //get them in there!
            using(var context = new New.RentlerEntities())
            {
                var ca = new List<New.BuildingAmenity>();
                foreach(var item in basicCommunity)
                {
                    ca.Add(new New.BuildingAmenity
                    {
                        BuildingId = item.BuildingId,
                        AmenityId = comMap[item.AmenityId]
                    });

                }

                Console.WriteLine("Prepped {0} community amenities, inserting!", ca.Count);

                context.BulkInsert(ca);

                basicCommunity.Clear();
            }

            //and on to property options
            var propOptions = new List<Old.BuildingAmenitiesWithOption>();
            using(var context = new Old.RentlerNewEntities())
                propOptions = context.BuildingAmenitiesWithOptions
                    .Where(b => b.AmenityId != 4 &&
                                b.AmenitiesWithOption.Category == "Property" &&
                                b.Option != "Forced Air").ToList();

            //convert those beasts
            var pwo = new List<New.BuildingAmenity>();
            foreach(var item in propOptions)
                pwo.Add(new New.BuildingAmenity
                {
                    BuildingId = item.BuildingId,
                    AmenityId = poMap[item.AmenityId][item.Option]
                });

            using(var context = new New.RentlerEntities())
            {
                context.BulkInsert(pwo);

                propOptions.Clear();
                pwo.Clear();
            }

            //finally, community options
            var comOptions = new List<Old.BuildingAmenitiesWithOption>();
            using(var context = new Old.RentlerNewEntities())
                comOptions = context.BuildingAmenitiesWithOptions
                    .Where(b => b.AmenitiesWithOption.Category == "Community").ToList();

            //convert 'em!
            var cwo = new List<New.BuildingAmenity>();
            foreach(var item in comOptions)
                cwo.Add(new New.BuildingAmenity
                {
                    BuildingId = item.BuildingId,
                    AmenityId = coMap[item.AmenityId][item.Option]
                });

            using(var context = new New.RentlerEntities())
            {
                context.BulkInsert(cwo);

                comOptions.Clear();
                cwo.Clear();
            }

            Console.WriteLine("Done!");
        }