Example #1
0
        // GET: Events
        public ActionResult Index()
        {
            ViewBag.Header = "Мероприятия";
            MafiaContext context = new MafiaContext();

            return(View(context.Events));
        }
Example #2
0
        public ActionResult Item(int id)
        {
            ViewBag.Header = "Мероприятия";
            MafiaContext context = new MafiaContext();
            Event        evt     = context.Events.Find(id);

            context.Entry(evt).Collection(x => x.EventPhotos).Load();
            return(View(evt));
        }
Example #3
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <MafiaContext>()
                          .UseInMemoryDatabase(databaseName: "Add_Test_Mafia_Db")
                          .Options;

            var _dbContext = new MafiaContext(options);

            _hub = new MafiaHub(_dbContext);
        }
Example #4
0
        public ActionResult Static(String id)
        {
            MafiaContext context = new MafiaContext();
            StaticPage   stP     = context.StaticPages.FirstOrDefault(p => p.Name == id);

            if (stP != null)
            {
                ViewBag.Header = stP.Header;
            }
            return(View(stP));
        }
Example #5
0
        private static MafiaContext GetOrCreateGame(DiscordSocketClient client, ulong guildId)
        {
            if (Games.ContainsKey(guildId))
            {
                return(Games[guildId]);
            }

            var context = new MafiaContext(client, guildId);

            Games[guildId] = context;
            return(context);
        }
Example #6
0
        public void Save(String id)
        {
            String htmlCont = Request["file"];

            htmlCont = Server.HtmlDecode(htmlCont);
            MafiaContext context = new MafiaContext();
            StaticPage   stPage  = context.StaticPages.FirstOrDefault(p => p.Name == id);

            if (stPage != null)
            {
                stPage.Content = htmlCont;
                context.SaveChanges();
            }
        }
Example #7
0
        private async Task <bool> EnsureSetup(MafiaContext context)
        {
            if (context == null)
            {
                await ReplyAsync("Cannot find the game or server you're talking about.");

                return(false);
            }

            if (!context.IsSetup())
            {
                await ReplyAsync("Woah! I don't think we're set up yet. Set up with `-setup`.");

                return(false);
            }

            return(true);
        }
Example #8
0
 private void SeedStaticPages(MafiaContext context)
 {
     context.StaticPages.AddOrUpdate(p => p.Name,
                                     new StaticPage()
     {
         Name = "About_us", Content = "<h1>From db</h1>", Header = "О нас"
     },
                                     new StaticPage()
     {
         Name = "News", Content = "<h1>From db</h1>", Header = "Новости"
     },
                                     new StaticPage()
     {
         Name = "Bands", Content = "<h1>From db</h1>", Header = "Банды"
     },
                                     new StaticPage()
     {
         Name = "GameInfo", Content = "<h1>From db</h1>", Header = "Описание игры"
     },
                                     new StaticPage()
     {
         Name = "Roles", Content = "<h1>From db</h1>", Header = "Роли"
     },
                                     new StaticPage()
     {
         Name = "Tactics", Content = "<h1>From db</h1>", Header = "Тактика"
     },
                                     new StaticPage()
     {
         Name = "Media", Content = "<h1>From db</h1>", Header = "Медиа"
     },
                                     new StaticPage()
     {
         Name = "Shop", Content = "<h1>From db</h1>", Header = "Магазин"
     },
                                     new StaticPage()
     {
         Name = "Partys", Content = "<h1>From db</h1>", Header = "Корпоративы"
     },
                                     new StaticPage()
     {
         Name = "Login", Content = "<h1>From db</h1>", Header = "Вход"
     });
 }
Example #9
0
        public void ImagesUpload(int id)
        {
            MafiaContext context = new MafiaContext();
            Event        evt     = context.Events.Find(id);

            if (!string.IsNullOrEmpty(Request.Headers["X-File-Name"]))
            {
                String serverPath  = string.Format("/Uploads/{0}", Request.Headers["X-File-Name"]);
                string path        = Server.MapPath(serverPath);
                Stream inputStream = Request.InputStream;
                using (FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate))
                {
                    inputStream.CopyTo(fileStream);
                    fileStream.Close();
                }
                EventPhoto evtPh = new EventPhoto()
                {
                    ParentEvent = evt,
                    Path        = serverPath
                };
                context.EventPhotos.Add(evtPh);
                context.SaveChanges();
            }
        }
Example #10
0
        private void SeedEventPhotos(MafiaContext context)
        {
            Event evt1 = context.Events.First(e => e.Name == "Открытие клуба");
            Event evt2 = context.Events.First(e => e.Name == "Приезд гостей");
            Event evt3 = context.Events.First(e => e.Name == "Вечеринка");
            Event evt4 = context.Events.First(e => e.Name == "Начало сезона");

            context.EventPhotos.AddOrUpdate(p => p.Path,
                                            new EventPhoto()
            {
                Path = @"/Images/1/image (1).jpg", EventPhotoId = 1, ParentEvent = evt1
            },
                                            new EventPhoto()
            {
                Path = @"/Images/1/image (1).png", EventPhotoId = 2, ParentEvent = evt1
            },
                                            new EventPhoto()
            {
                Path = @"/Images/1/image (3).png", EventPhotoId = 3, ParentEvent = evt1
            },
                                            new EventPhoto()
            {
                Path = @"/Images/1/image (4).png", EventPhotoId = 4, ParentEvent = evt1
            },
                                            new EventPhoto()
            {
                Path = @"/Images/2/image (1).png", EventPhotoId = 5, ParentEvent = evt2
            },
                                            new EventPhoto()
            {
                Path = @"/Images/2/image (2).png", EventPhotoId = 6, ParentEvent = evt2
            },
                                            new EventPhoto()
            {
                Path = @"/Images/2/image (3).png", EventPhotoId = 7, ParentEvent = evt2
            },
                                            new EventPhoto()
            {
                Path = @"/Images/3/image (1).png", EventPhotoId = 8, ParentEvent = evt3
            },
                                            new EventPhoto()
            {
                Path = @"/Images/3/image (4).png", EventPhotoId = 9, ParentEvent = evt3
            },
                                            new EventPhoto()
            {
                Path = @"/Images/3/image (3).png", EventPhotoId = 10, ParentEvent = evt3
            },
                                            new EventPhoto()
            {
                Path = @"/Images/4/image (1).png", EventPhotoId = 11, ParentEvent = evt4
            },
                                            new EventPhoto()
            {
                Path = @"/Images/4/image (2).png", EventPhotoId = 12, ParentEvent = evt4
            },
                                            new EventPhoto()
            {
                Path = @"/Images/4/image (3).png", EventPhotoId = 13, ParentEvent = evt4
            });
        }
Example #11
0
 public MafiaHub(MafiaContext context)
 {
     _context = context;
 }