Ejemplo n.º 1
0
 private void PopulateDaysWithEventData(Event ev)
 {
     var allDays = db.DaysOpen;
     var eventDays = new HashSet<DayOfWeek>(ev.DaysOpen.Select(d => d.DayOfWeek));
     var viewModel = new List<DaysWithEventData>();
     foreach (var day in allDays)
     {
         viewModel.Add(new DaysWithEventData
         {
             DayID = day.ID,
             DayOpen = day.DayOfWeek,
             Assigned = eventDays.Contains(day.DayOfWeek) 
         });
     }
     ViewBag.DaysOpen = viewModel;
 }
Ejemplo n.º 2
0
        private void UpdateEventDays(string[] selectedDays, Event eventToUpdate)
        {
            if (selectedDays == null)
            {
                eventToUpdate.DaysOpen = new List<DayOpen>();
                return;
            }

            var selectedDaysHS = new HashSet<string>(selectedDays);
            var eventDays = new HashSet<DayOfWeek>
                (eventToUpdate.DaysOpen.Select(c => c.DayOfWeek));
            foreach (var entry in db.DaysOpen)
            {
                if (selectedDaysHS.Contains(entry.ID.ToString()))
                {
                    if (!eventDays.Contains(entry.DayOfWeek))
                    {
                        eventToUpdate.DaysOpen.Add(entry);
                    }
                }
                else
                {
                    if (eventDays.Contains(entry.DayOfWeek))
                    {
                        eventToUpdate.DaysOpen.Remove(entry);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        // GET: Event/Create
        public ActionResult Create()
        {
            ViewBag.VenueID = new SelectList(db.Venues, "VenueID", "VenueName");
            ViewBag.DanceStyleID = new SelectList(db.DanceStyles, "DanceStyleID", "StyleName");

            var ev = new Event();
            ev.DaysOpen = new List<DayOpen>();
            PopulateDaysWithEventData(ev);
            return View();
        }