public async Task <IActionResult> Index(string eventCategory, string searchString)
        {
            IQueryable <string> categoryQuery = from m in _context.Events
                                                orderby m.Category
                                                select m.Category;
            var @event = from m in _context.Events
                         select m;

            if (!string.IsNullOrEmpty(searchString))
            {
                @event = @event.Where(s => s.Description.Contains(searchString));
            }
            if (!string.IsNullOrEmpty(eventCategory))
            {
                @event = @event.Where(x => x.Category == eventCategory);
            }

            var eventCategoryVM = new EventCategoryViewModel {
                Categories = new SelectList(await categoryQuery.Distinct().ToListAsync()),
                Events     = await @event.ToListAsync()
            };

            return(View(eventCategoryVM));
            // var @event = from m in _context.Events
            //             select m;

            // if (!String.IsNullOrEmpty(searchString)){
            //     @event = @event.Where(s => s.Description.Contains(searchString));
            // }
            // return View(await @event.ToListAsync());
        }
示例#2
0
        public ActionResult SaveEvent(EventCategoryViewModel vm, HttpPostedFileBase file, string newItem = null)
        {
            if (SpamDetector.IsContentSpam(vm.GamingEvent.Title))
            {
                return(RedirectToAction("Index", "Post"));
            }
            //Verify whether user has neccessary data
            ApplicationUser user = null;
            string          id   = User.Identity.GetUserId();

            if (id != string.Empty && id != null)
            {
                user = context.Users.Where(a => a.Id == id).First();
            }


            int idd = vm.GamingEvent.GamingEventId;

            var gameEvent = vm.GamingEvent;

            if (file != null && file.ContentLength > 0)
            {
                if (Path.GetExtension(file.FileName).ToLower() == ".jpg" || Path.GetExtension(file.FileName).ToLower() == ".png")
                {
                    var sourceImage = Image.FromStream(file.InputStream);

                    sourceImage = ResizeImage(sourceImage, 500, 500);

                    //Generowanie plik
                    var fileExt  = Path.GetExtension(file.FileName);
                    var filename = Guid.NewGuid() + fileExt; // Unikalny identyfikator + rozszerzenie

                    //W jakim folderze ma byc umiesczony dany plik oraz jego nazwa! Oraz zapis
                    var path = Path.Combine(Server.MapPath(AppConfig.ImagesGamingEventFolder), filename);
                    //file.SaveAs(path);
                    sourceImage.Save(path);
                    gameEvent.MainPicture = filename;
                }
            }
            else if (file == null && newItem != null && newItem != String.Empty)
            {
                var fractImg = FractalGenerator.GenereateFractal1(user.Email);
                var filename = Guid.NewGuid() + ".jpg";
                var path     = Path.Combine(Server.MapPath(AppConfig.ImagesGamingEventFolder), filename);
                fractImg.Save(path);
                gameEvent.MainPicture = filename;
            }

            gameEvent.UserId    = user.Id;
            gameEvent.Publisher = user;

            context.GamingEvents.AddOrUpdate(gameEvent);
            context.SaveChanges();

            return(RedirectToAction("Events", "Manage"));
        }
示例#3
0
        public ActionResult AddEvent()
        {
            var vm = new EventCategoryViewModel()
            {
                EventCategory = context.CategoryEvents.ToList(),
                GamingEvent   = new GamingEvent()
            };

            return(View("~/Views/GamingEvent/AddGameEvent.cshtml", vm));
        }
示例#4
0
        private void NavigateToEventsByCategory(EventCategoryViewModel category)
        {
            if (category == null)
            {
                throw new ArgumentNullException();
            }

            NavigationService.Navigate(new Uri(string.Format("/EventsInCategory.xaml?location={0}&latitude={1}&longitude={2}&category={3}", _model.MyLocation.Name, _model.MyLocation.Latitude, _model.MyLocation.Longitude, category.Name)
                                               , UriKind.Relative));
        }
示例#5
0
        //GET: Selling
        public async Task <IActionResult> Index()
        {
            var @event = from m in _context.Events
                         select m;
            var x = new EventCategoryViewModel
            {
                Events = await @event.ToListAsync()
            };

            return(View(x));
        }
示例#6
0
        public ActionResult EditEvent(int id)
        {
            var gameEvent = context.GamingEvents.Find(id);

            if (gameEvent == null)
            {
                return(RedirectToAction("Index", new { errorMessage = "Nie ma takiego eventu" }));
            }

            var vm = new EventCategoryViewModel()
            {
                EventCategory = context.CategoryEvents.ToList(),
                GamingEvent   = gameEvent
            };

            return(View("~/Views/GamingEvent/EditGameEvent.cshtml", vm));
        }
示例#7
0
        public ActionResult AddEvent(EventCategoryViewModel vm, HttpPostedFileBase file)
        {
            ApplicationUser user = null;
            string          id   = User.Identity.GetUserId();

            if (id != string.Empty && id != null)
            {
                user = context.Users.Where(a => a.Id == id).First();
            }

            var    GameEvent  = vm.GamingEvent;
            string fileToSave = "";

            if (file != null && file.ContentLength > 0)
            {
                if (Path.GetExtension(file.FileName).ToLower() == ".jpg" || Path.GetExtension(file.FileName).ToLower() == ".png")
                {
                    var sourceImage = Image.FromStream(file.InputStream);

                    sourceImage = ResizeImage(sourceImage, 500, 500);

                    //Generowanie plik
                    var fileExt  = Path.GetExtension(file.FileName);
                    var filename = Guid.NewGuid() + fileExt; // Unikalny identyfikator + rozszerzenie

                    //W jakim folderze ma byc umiesczony dany plik oraz jego nazwa! Oraz zapis
                    var path = Path.Combine(Server.MapPath(AppConfig.ImagesGamingEventFolder), filename);
                    //file.SaveAs(path);
                    sourceImage.Save(path);
                    fileToSave = filename;
                }
            }

            GameEvent.UserId = user.Id;
            if (fileToSave != string.Empty)
            {
                GameEvent.MainPicture = fileToSave;
            }
            context.GamingEvents.Add(GameEvent);
            user.UserGamingEvent.Add(GameEvent);
            context.SaveChanges();

            return(RedirectToAction("Index", "Manage"));
        }