Esempio n. 1
0
 public MySQLAuditoriumEvent(AuditoriumEvent evt)
 {
     AuditoriumEventId = evt.AuditoriumEventId;
     Name = evt.Name;
     CalendarId = evt.Calendar.CalendarId;
     RingId = evt.Ring.RingId;
     AuditoriumId = evt.Auditorium.AuditoriumId;
 }
Esempio n. 2
0
 public AuditoriumEventView(AuditoriumEvent evt)
 {
     AuditoriumEventId = evt.AuditoriumEventId;
     Name = evt.Name;
     Calendar = evt.Calendar.Date.ToString("d.M.yyyy");
     Ring = evt.Ring.Time.ToString("H:mm");
     Auditorium = evt.Auditorium.Name;
 }
Esempio n. 3
0
        private void add_Click(object sender, EventArgs e)
        {
            if (useDataSet.Checked)
            {
                var dow = startDate.Value.DayOfWeek;
                var calendarList = new List<Calendar>();
                var date = startDate.Value;
                do
                {
                    if (date.DayOfWeek == dow)
                    {
                        var calendar = _repo.GetFirstFiltredCalendar(c => c.Date.Date == date.Date);

                        if (calendar == null)
                        {
                            MessageBox.Show("Не найдена дата: " + date.ToString("d.m.Y"), "Oops");
                            return;
                        }

                        var newEvent = new AuditoriumEvent
                        {
                            Name = eventName.Text,
                            Calendar = calendar,
                            Ring = _repo.GetRing((int)eventTime.SelectedValue),
                            Auditorium = _repo.GetAuditorium((int)eventAuditorium.SelectedValue)
                        };

                        _repo.AddAuditoriumEvent(newEvent);
                    }

                    date = date.AddDays(1);
                } while(date <= finishDate.Value);

            }
            else
            {
                var calendar = _repo.GetFirstFiltredCalendar(c => c.Date.Date == eventDate.Value.Date);

                if (calendar == null)
                {
                    MessageBox.Show("Не найдена дата", "Oops");
                    return;
                }

                var newEvent = new AuditoriumEvent
                {
                    Name = eventName.Text,
                    Calendar = calendar,
                    Ring = _repo.GetRing((int)eventTime.SelectedValue),
                    Auditorium = _repo.GetAuditorium((int)eventAuditorium.SelectedValue)
                };

                _repo.AddAuditoriumEvent(newEvent);
            }
            RefreshView();
        }
        public void UpdateAuditoriumEvent(AuditoriumEvent ae)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                var curAE = context.AuditoriumEvents.FirstOrDefault(evt => evt.AuditoriumEventId == ae.AuditoriumEventId);

                curAE.Name = ae.Name;
                curAE.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == ae.Calendar.CalendarId);
                curAE.Ring = context.Rings.FirstOrDefault(r => r.RingId == ae.Ring.RingId);
                curAE.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == ae.Auditorium.AuditoriumId);

                context.SaveChanges();
            }
        }
        public AuditoriumEvent AddAuditoriumEvent(AuditoriumEvent ae)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                ae.AuditoriumEventId = 0;

                ae.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == ae.Calendar.CalendarId);
                ae.Ring = context.Rings.FirstOrDefault(r => r.RingId == ae.Ring.RingId);
                ae.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == ae.Auditorium.AuditoriumId);

                context.AuditoriumEvents.Add(ae);
                context.SaveChanges();

                return ae;
            }
        }