Example #1
0
        public ActionResult AllPlaces([FromServices] MeetUkraineContext a)
        {
            //using (var a = new MeetUkraineContext())

            List <Place> places = a.Places.ToList();

            return(View(places));
        }
Example #2
0
 public ActionResult AddNewPlace([FromServices] MeetUkraineContext a, Place newPlace)
 {
     //using (var a = new MeetUkraineContext())
     {
         a.Places.Add(newPlace);
         a.SaveChanges();
     }
     return(View("Index"));
 }
Example #3
0
 public ActionResult AddComent(int PlaceId, PlaceComment comment)
 {
     using (var a = new MeetUkraineContext())
     {
         Place test = a.Places.Where(item => item.PlaceId == PlaceId).FirstOrDefault();
         test.PlaceComments.Add(comment);
         a.SaveChanges();
     }
     return(View());
 }
Example #4
0
        public IActionResult Index([FromServices] MeetUkraineContext ctx)
        {
            string a = "hey";

            ViewBag.data = a;

            //using (var ctx = new MeetUkraineContext() )

            List <Place> places = new List <Place>();

            places = ctx.Places.ToList();
            //places.Count();
            //ViewBag.places = ctx.Places.ToList();
            ViewBag.Places = places;
            ViewBag.Size   = places.Count;


            return(View());
        }
Example #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <User> u, RoleManager <IdentityRole> r, MeetUkraineContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            DataInitializer.SeedData(u, r, context).Wait();

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