コード例 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ResturantContext resturantContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
                {
                    HotModuleReplacement = true
                });
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            resturantContext.Seed();

            AutoMapper.Mapper.Initialize(
                cfg =>
            {
                cfg.CreateMap <Resturant, ResturantDTO>().ReverseMap();
                cfg.CreateMap <Review, ReviewDTO>().ReverseMap();
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                routes.MapSpaFallbackRoute(
                    name: "spa-fallback",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
コード例 #2
0
 public ItemController(ResturantContext context)
 {
     _context = context;
 }
コード例 #3
0
 public DrinkController(ResturantContext context, IWebHostEnvironment hosting)
 {
     _context = context;
     _hosting = hosting;
 }
コード例 #4
0
 public OrderController(ResturantContext context)
 {
     _context = context;
 }
コード例 #5
0
 public StaffRepository(ResturantContext dbContext)
 {
     DbContext = dbContext;
 }
コード例 #6
0
 public ResturantRepository(ResturantContext context)
 {
     _context = context;
 }
コード例 #7
0
 public CustomerController(ResturantContext context)
 {
     _context = context;
 }
コード例 #8
0
        public static void Seed(this ResturantContext context)
        {
            if (context.Resturants.Any())
            {
                return;
            }

            var resturants = new List <Resturant>()
            {
                new Resturant()
                {
                    Name        = "Nando's",
                    Description = "Portugese Chicken Resturant",
                    Latitude    = "0.13532",
                    Longitude   = "1.4568",
                    Address     = "25 Wherry Road",
                    Address2    = "Riverside Entertainment Complex",
                    City        = "Norwich",
                    County      = "Norfolk",
                    PhoneNumber = "01603 345234",
                    WebsiteUrl  = "www.nandos.co.uk",
                    DietOptions = new List <DietOption>()
                    {
                        new DietOption()
                        {
                            DietType = "GF"
                        },
                        new DietOption()
                        {
                            DietType = "DF"
                        }
                    },
                    Reviews = new List <Review>()
                    {
                        new Review()
                        {
                            Title       = "Gluten Free Heaven",
                            Description = "As it's chicken, this is a perfect place for some gluten and dairy free goodness",
                            GfScore     = 5,
                            DfScore     = 5,
                            MfScore     = 0,
                            PriceRating = 2
                        },
                        new Review()
                        {
                            Title       = "Hope you like chicken",
                            Description = "Great for all intolerences, but variety is not there as it specialises in chicken dishes.",
                            GfScore     = 3,
                            DfScore     = 3,
                            MfScore     = 0,
                            PriceRating = 3
                        },
                        new Review()
                        {
                            Title       = "Had Better",
                            Description = "Chicken was tough and boring",
                            GfScore     = 2,
                            DfScore     = 4,
                            MfScore     = 0,
                            PriceRating = 4
                        },
                        new Review()
                        {
                            Title       = "Cant beat a cheeky nandos.",
                            Description = "always my go to spot for gluten free goodness, but the prices are rising",
                            GfScore     = 4,
                            DfScore     = 4,
                            MfScore     = 1,
                            PriceRating = 5
                        }
                    }
                },
                new Resturant()
                {
                    Name        = "Cafe Maine",
                    Description = "Bistro Cafe",
                    Latitude    = "0.1222",
                    Longitude   = "1.43368",
                    Address     = "25 Cromer Road",
                    Address2    = "Sheringham",
                    City        = "Norwich",
                    County      = "Norfolk",
                    PhoneNumber = "01603 322334",
                    WebsiteUrl  = "www.cafemaine.co.uk",
                    DietOptions = new List <DietOption>()
                    {
                        new DietOption()
                        {
                            DietType = "GF"
                        },
                        new DietOption()
                        {
                            DietType = "DF"
                        },
                        new DietOption()
                        {
                            DietType = "MF"
                        }
                    },
                    Reviews = new List <Review>()
                    {
                        new Review()
                        {
                            Title       = "Very bad",
                            Description = "No Choice",
                            GfScore     = 1,
                            DfScore     = 1,
                            MfScore     = 2,
                            PriceRating = 4
                        },
                        new Review()
                        {
                            Title       = "good location and food",
                            Description = "cheap and cheerfull in a nice place",
                            GfScore     = 4,
                            DfScore     = 5,
                            MfScore     = 3,
                            PriceRating = 3
                        },
                        new Review()
                        {
                            Title       = "Seen Worse cafe's",
                            Description = "we got what we paid for",
                            GfScore     = 3,
                            DfScore     = 5,
                            MfScore     = 3,
                            PriceRating = 3
                        },
                        new Review()
                        {
                            Title       = "Top Service and good options",
                            Description = "cant go wrong, options for everyone and good staff and service",
                            GfScore     = 4,
                            DfScore     = 4,
                            MfScore     = 5,
                            PriceRating = 4
                        }
                    }
                }
            };

            context.Resturants.AddRange(resturants);
            context.SaveChanges();
        }