private void InstallPictures(Model.Models.DashoorContext context)
        {
            for (int i = 1; i <= 9; i++)
            {
                context.Pictures.Add(new Model.Models.Picture()
                {
                    MimeType    = "image/jpeg",
                    ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added
                });

                context.SaveChanges();

                context.ListingPictures.Add(new Model.Models.ListingPicture()
                {
                    ListingID   = i,
                    PictureID   = i,
                    ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added
                });

                // Copy files
                var pathFrom = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/images/sample/listing"), string.Format("{0}.{1}", i.ToString("00000000"), "jpg"));
                var pathTo   = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/images/listing"), string.Format("{0}.{1}", i.ToString("00000000"), "jpg"));
                File.Copy(pathFrom, pathTo, true);
            }
        }
        private void InstallListingTypes(Model.Models.DashoorContext context)
        {
            context.ListingTypes.Add(new Dashoor.Model.Models.ListingType()
            {
                Name            = "Offer",
                ButtonLabel     = "Book",
                OrderTypeID     = (int)Enum_ListingOrderType.DateRange,
                OrderTypeLabel  = "Number of days",
                PriceUnitLabel  = "Per day",
                PaymentEnabled  = true,
                PriceEnabled    = true,
                ShippingEnabled = false,
                ObjectState     = Repository.Pattern.Infrastructure.ObjectState.Added
            });

            context.SaveChanges();
        }
Beispiel #3
0
        public async Task <ActionResult> Install(InstallModel model)
        {
            System.Data.Entity.Database.SetInitializer(new DashoorDatabaseInitializer(model));

            // initialize and create database
            using (var context = new Model.Models.DashoorContext())
            {
                context.Database.Initialize(true);
                context.SaveChanges();
            }

            // Sign in user
            var user = UserManager.FindByEmail(model.Email);
            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

            InstallPlugins();

            return(RedirectToAction("Index", "Home", new { area = "" }));
        }