Example #1
0
        public ActionResult Edit(Guid id)
        {
            try
            {
                Theme item = _themeRepository.GetById(id);

                if (item == null)
                {
                    Request.Flash("error", "Thema niet gevonden");

                    return(RedirectToAction("Index"));
                }

                ThemeViewModel model = new ThemeViewModel()
                {
                    Id          = item.Id,
                    Title       = item.Title,
                    Description = item.Description
                };

                return(View(model));
            }
            catch (Exception e)
            {
                Request.Flash("error", "Er is iets mis gegaan: " + e.Message);

                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Create(Guid id)
        {
            try
            {
                var eventItem = _eventRepository.GetById(id);

                var themeDescription = "";
                var themeTitle       = "";
                if (eventItem.Theme != null)
                {
                    Theme theme = _themeRepository.GetById(eventItem.Theme.Id);
                    if (theme != null)
                    {
                        themeTitle       = theme.Title.ToUpper();
                        themeDescription = theme.Description;
                    }
                }

                var registrationViewModel = new RegistrationViewModel()
                {
                    Title            = eventItem.TimeRange.ToString(),
                    EventId          = eventItem.Id,
                    ThemeTitle       = themeTitle,
                    ThemeDescription = themeDescription
                };

                return(View(registrationViewModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #3
0
        public void Should_return_theme_by_id()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new ThemeRepository(Shared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var theme      = repository.GetById(_themeId1);

                Assert.NotNull(theme);
            }
        }
        public IActionResult GetById(/*[FromRoute]*/ int Id)
        {
            Modeles.ThemeDetailed theme = _themeRepo.GetById(Id).DalToApiThemeDetailed();

            theme.Adresse   = _adRepo.GetById(theme.AdresseID);
            theme.TypeTheme = _ttRepo.GetByTheme(theme.ThemeID);


            return(Ok(theme));
        }
Example #5
0
        public void Should_return_null_if_theme_is_deleted()
        {
            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository = new ThemeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var theme      = repository.GetById(_deletedThemeId);

                Assert.Null(theme);
            }
        }
Example #6
0
        public ActionResult Create(FormCollection collection)
        {
            var dumpstore = _dumpstoreRepository.GetById(new Guid("B980E94C-4436-4966-B291-2B377080E6E3"));
            var theme     = _themeRepository.GetById(new Guid(collection["ThemeId"]));

            var startDate = DateTime.Parse(collection["StartTime"]);
            var endDate   = DateTime.Parse(collection["EndTime"]);

            var maxPersonsPerHour = Convert.ToInt32(collection["MaxPersons"]);
            var interval          = new Interval(Convert.ToInt32(collection["Amount"]), (Unit)Enum.Parse(typeof(Unit), collection["Unit"]));
            var publishUp         = DateTime.Parse(collection["PublishUp"]);

            var events = Event.CreateRange(dumpstore, startDate, endDate, interval, maxPersonsPerHour, publishUp, theme);

            foreach (var newEvent in events)
            {
                _eventRepository.Insert(newEvent);
            }

            Request.Flash("success", "Evenementen zijn opgeslagen");

            return(RedirectToAction("Index", new { date = startDate.ToString("yyyy-MM-dd") }));
        }
Example #7
0
        public void Should_save_new_theme()
        {
            var newTheme = ThemeFactory.Theme(Guid.NewGuid(), "Name 3", "Description 3", "Folder 3");

            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new ThemeRepository(Shared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                repository.Create(newTheme);
            }

            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new ThemeRepository(Shared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var theme      = repository.GetById(newTheme.Id);

                Assert.NotNull(theme);
            }
        }
Example #8
0
        public void Should_update_theme()
        {
            const string newThemeDescription = "New Description 1";

            var themeToUpdate = ThemeFactory.Theme(_themeId1, "Name 1", newThemeDescription, "Folder 1");

            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new ThemeRepository(Shared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                repository.Update(themeToUpdate);
            }

            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository   = new ThemeRepository(Shared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var updatedTheme = repository.GetById(_themeId1);

                Assert.AreEqual(newThemeDescription, updatedTheme.Description);
            }
        }
Example #9
0
        private string GetThemeDescription(DateTime date)
        {
            var events = _eventRepository.ListByDate(date);

            Theme theme = null;

            if (events.Count() > 0)
            {
                if (events.LastOrDefault().Theme != null)
                {
                    theme = _themeRepository.GetById(events.LastOrDefault().Theme.Id);
                    if (theme != null)
                    {
                        return("<h5>" + theme.Title.ToUpper() + "</h5><p>" + theme.Description + "</p>");
                    }
                }
                return("<h5>Alle thema's</h5>");
            }

            return("");
        }
Example #10
0
        public IHttpActionResult GetByDate(string date)
        {
            var items = _eventRepository.ListByDate(DateTime.Parse(date)).Where(x => x.MaximumNumberOfVisitors > 0);

            var events = new List <EventViewModel>();

            foreach (var eventItem in items)
            {
                int pendingCount    = _registrationRepository.GetPendingCount(eventItem);
                int registeredCount = _registrationRepository.GetRegisteredCount(eventItem);
                int visitedCount    = _registrationRepository.GetVisitedCount(eventItem);

                string themeTitle = "";
                if (eventItem.Theme != null)
                {
                    Theme theme = _themeRepository.GetById(eventItem.Theme.Id);
                    if (theme != null)
                    {
                        themeTitle = theme.Title.ToUpper();
                    }
                }

                events.Add(new EventViewModel()
                {
                    Id         = eventItem.Id,
                    Registered = registeredCount,
                    MaxPersons = eventItem.MaximumNumberOfVisitors,
                    Available  = eventItem.MaximumNumberOfVisitors - registeredCount,
                    Pending    = pendingCount,
                    StartTime  = eventItem.TimeRange.Start.ToShortTimeString(),
                    EndTime    = eventItem.TimeRange.End.ToShortTimeString(),
                    Visited    = visitedCount,
                    ThemeTitle = themeTitle,
                });
            }

            return(Ok(events));
        }