/// <summary>
        /// Seeds the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public static void Seed(HostaliandoContext context)
        {
            var list = new List <BookingSource>();

            list.Add(new BookingSource {
                Name = "Fisico", Description = "Cuando la persona llega al hostal", Color = "#3361FF", Icon = "onsite.png"
            });
            list.Add(new BookingSource {
                Name = "TripAdvisor", Description = "Por trip advisor", Color = "#05771F", Icon = "tripadvisor.png"
            });
            list.Add(new BookingSource {
                Name = "Despegar", Description = "Por Despegar", Color = "#180577", Icon = "despegar.png"
            });
            list.Add(new BookingSource {
                Name = "Airbnb", Description = "Por Airbnb", Color = "#F178BC", Icon = "aribnb.png"
            });

            foreach (var item in list)
            {
                if (!context.BookingSources.Any(c => c.Name.Equals(item.Name)))
                {
                    context.BookingSources.Add(item);
                }
            }

            context.SaveChanges();
        }
Beispiel #2
0
 /// <summary>
 /// Ensures the seeding.
 /// </summary>
 /// <param name="context">The context.</param>
 public static void EnsureSeeding(this HostaliandoContext context)
 {
     if (EnsureSeedingExtension.AreAllMigrationsApplied(context))
     {
         EnsureSeedingExtension.Seed(context);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Seeds the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 private static void Seed(HostaliandoContext context)
 {
     SeedLocations.Seed(context);
     SeedCurrencies.Seed(context);
     SeedUsers.Seed(context);
     SeedBookingSources.Seed(context);
     SeedSettings.Seed(context);
     SeedNotifications.Seed(context);
 }
Beispiel #4
0
        /// <summary>
        /// Validates if are all migrations applied.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>true if all migrations are applied</returns>
        private static bool AreAllMigrationsApplied(HostaliandoContext context)
        {
            var applied = context.GetService <IHistoryRepository>()
                          .GetAppliedMigrations()
                          .Select(m => m.MigrationId);

            var total = context.GetService <IMigrationsAssembly>()
                        .Migrations
                        .Select(m => m.Key);

            return(!total.Except(applied).Any());
        }
Beispiel #5
0
        /// <summary>
        /// Seeds the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public static void Seed(HostaliandoContext context)
        {
            var users = new List <User>();

            users.Add(new User {
                Name = "Gabriel", Email = "*****@*****.**", Password = "******", Salt = "123456", RoleId = 1, TimeZone = -5
            });

            foreach (var item in users)
            {
                if (!context.Users.Any(c => c.Email.Equals(item.Email)))
                {
                    context.Users.Add(item);
                }
            }

            context.SaveChanges();
        }
        /// <summary>
        /// Seeds the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public static void Seed(HostaliandoContext context)
        {
            var list = new List <Currency>();

            list.Add(new Currency {
                Name = "COP", Symbol = "$"
            });
            list.Add(new Currency {
                Name = "USD", Symbol = "$"
            });

            foreach (var item in list)
            {
                if (!context.Currencies.Any(c => c.Name.Equals(item.Name)))
                {
                    context.Currencies.Add(item);
                }
            }

            context.SaveChanges();
        }
        /// <summary>
        /// Seeds the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public static void Seed(HostaliandoContext context)
        {
            var list = new Notification[]
            {
                new Notification
                {
                    Id           = Convert.ToInt32(NotificationType.Welcome),
                    Name         = "Registro de usuarios",
                    Active       = true,
                    EmailHtml    = "<h2 style=\"color: #304a6f;text-align: center;font-size: 22px;\"><b>!Nos alegra mucho que te hayas unido a Hostaliando!</b></h2>                      <p><br></p> <p>Hola %%NotifiedUser.Name%%,</p>                      <p>queremos comunicarte que el perfil ya está creado en nuestra página y podrás empezar a:</p>  <ul>  	<li>Crear habitaciones</li> 	<li>Crear reservas</li> 	<li>Organizar tu calendario</li>  </ul>  <p>Para empezar debes cambiar tu clave.</p>                      <p><a href=\"%%RootUrl%%/passwordrecovery/%%User.PasswordRecoveryToken%%\" style=\"color: #FFF; background: #3C75C2; font-size: 20px;  text-decoration: none; margin: 10px auto; display: block; min-width: 140px; text-align: center; border-radius: 6px; padding: 10px 0;\">Crear mi clave</a></p>",
                    EmailSubject = "Bienvenido a Hostaliando",
                    SystemText   = null,
                    IsEmail      = true,
                    IsSystem     = false,
                    Tags         = "%%NotifiedUser.Name%%,%%User.PasswordRecoveryToken%%"
                },
                new Notification
                {
                    Id           = Convert.ToInt32(NotificationType.PasswordRecovery),
                    Name         = "Recuperación de clave",
                    Active       = true,
                    EmailHtml    = "<h2 style=\"color: #304a6f;text-align: center;font-size: 22px;\"><b>!Cambia tu clave!</b></h2>                       <p><br></p>                       <p>Hola %%NotifiedUser.Name%%,</p>                       <p>ya puedes realizar el cambio de la clave:</p>                       <p><a href=\"%%Url%%\" style=\"color: #FFF; background: #3C75C2; font-size: 20px;  text-decoration: none; margin: 10px auto; display: block; min-width: 140px; text-align: center; border-radius: 6px; padding: 10px 0;\">Cambiar clave</a></p>",
                    EmailSubject = "Recuperar clave de Hostaliando",
                    SystemText   = null,
                    IsEmail      = true,
                    IsSystem     = false,
                    Tags         = "%%NotifiedUser.Name%%"
                }
            };

            foreach (var item in list)
            {
                if (!context.Notifications.Any(c => c.Id.Equals(item.Id)))
                {
                    context.Notifications.Add(item);
                }
            }

            context.SaveChanges();
        }
        /// <summary>
        /// Seeds the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public static void Seed(HostaliandoContext context)
        {
            var list = new SystemSetting[]
            {
                new SystemSetting()
                {
                    Name = "GeneralSettings.SiteUrl", Value = "http://*****:*****@gmail.com"
                },
                new SystemSetting()
                {
                    Name = "NotificationSettings.EmailSenderName", Value = "Hostaliando"
                },
                new SystemSetting()
                {
                    Name = "NotificationSettings.SmtpHost", Value = "smtp.gmail.com"
                },
                new SystemSetting()
                {
                    Name = "NotificationSettings.SmtpPassword", Value = "False"
                },
                new SystemSetting()
                {
                    Name = "NotificationSettings.SmtpPort", Value = "465"
                },
                new SystemSetting()
                {
                    Name = "NotificationSettings.SmtpUser", Value = "*****@*****.**"
                },
                new SystemSetting()
                {
                    Name = "NotificationSettings.SmtpUseSsl", Value = "True"
                }
            };

            foreach (var item in list)
            {
                if (!context.SystemSettings.Any(c => c.Name.Equals(item.Name)))
                {
                    context.SystemSettings.Add(item);
                }
            }

            context.SaveChanges();
        }