示例#1
0
        public void AttendSession(int personId, int sessionId)
        {
            using (var db = new CC.Data.CCDB())
            {
                // 1. delete old one
                Data.Session newSession = db.Sessions.Find(sessionId);
                if (newSession == null)
                {
                    throw new Exception("Session not found");
                }

                var oldSession = (from sa in db.SessionAttendees.Include("Session.Timeslot")
                                  where sa.Person_ID == personId && sa.Session.ID == sessionId
                                  select sa).SingleOrDefault();

                //if (oldSession != null)
                //    db.SessionAttendees.Remove(oldSession);

                if (oldSession == null)
                {
                    // 2. insert new one
                    db.SessionAttendees.Add(new CC.Data.SessionAttendee()
                    {
                        Person_ID = personId, Session_ID = sessionId, Comment = string.Empty, SessionRating = 0, SpeakerRating = 0
                    });
                }

                db.SaveChanges();
            }
        }
示例#2
0
        public void CreateSponsor(Sponsor sponsor)
        {
            using (var db = new CC.Data.CCDB())
            {
                db.Sponsors.Add(sponsor.Map());

                db.SaveChanges();
            }
        }
示例#3
0
        public void DeleteSponsor(int id)
        {
            using (var db = new CC.Data.CCDB())
            {
                var s = db.Sponsors.Find(id);

                db.Sponsors.Remove(s);

                db.SaveChanges();
            }
        }
示例#4
0
        public void DeleteAnnouncement(int id)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Announcement announcement = (from a in db.Announcements where a.ID == id select a).FirstOrDefault();

                db.Announcements.Remove(announcement);

                db.SaveChanges();
            }
        }
示例#5
0
        public void UpdateTrack(Track track)
        {
            using (var db = new CC.Data.CCDB())
            {
                var t = db.Tracks.Find(track.ID);

                t.Name        = track.Name;
                t.Description = track.Description;

                db.SaveChanges();
            }
        }
示例#6
0
        public void AddAdministrator(int personId)
        {
            using (var db = new CC.Data.CCDB())
            {
                var p = db.People.Find(personId);

                if (p == null) throw new ArgumentException("Person not found");

                p.IsAdmin = true;

                db.SaveChanges();
            }
        }
示例#7
0
        public void UpdateTimeslot(Timeslot timeslot)
        {
            //ToDo: Add error handling here. Brian Hall had an unhandled exception when he tried to submit a timeslot that was a past date-time.
            using (var db = new CC.Data.CCDB())
            {
                var t = db.Timeslots.Find(timeslot.ID);

                t.Name      = timeslot.Name;
                t.StartTime = timeslot.StartTime;
                t.EndTime   = timeslot.EndTime;

                db.SaveChanges();
            }
        }
示例#8
0
        public void UpdateSponsor(Sponsor sponsor)
        {
            using (var db = new CC.Data.CCDB())
            {
                var s = db.Sponsors.Find(sponsor.ID);

                s.Name             = sponsor.Name;
                s.Description      = sponsor.Description;
                s.WebsiteUrl       = sponsor.WebsiteUrl;
                s.SponsorshipLevel = sponsor.SponsorshipLevel;
                //s.ImageUrl = sponsor.ImageUrl;
                s.Image = sponsor.Image;

                db.SaveChanges();
            }
        }
示例#9
0
        public void RemoveAdministrator(int personId)
        {
            using (var db = new CC.Data.CCDB())
            {
                var p = db.People.Find(personId);

                if (p == null)
                {
                    throw new ArgumentException("Person not found");
                }

                p.IsAdmin = false;

                db.SaveChanges();
            }
        }
示例#10
0
        public void CreateTrack(Track track)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Track t = new Data.Track()
                {
                    Event_ID    = track.EventID,
                    Name        = track.Name,
                    Description = track.Description
                };

                db.Tracks.Add(t);

                db.SaveChanges();
            }
        }
示例#11
0
        public void DeleteTrack(int id)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Track track = (from t in db.Tracks.Include("Sessions") where t.ID == id select t).FirstOrDefault();

                if (track.Sessions.Count > 0)
                {
                    throw new Exception("Can't delete a track that contains sessions!");
                }

                db.Tracks.Remove(track);

                db.SaveChanges();
            }
        }
示例#12
0
        public void CreateTimeslot(Timeslot timeslot)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Timeslot t = new Data.Timeslot()
                {
                    Event_ID  = timeslot.EventID,
                    Name      = timeslot.Name,
                    StartTime = timeslot.StartTime,
                    EndTime   = timeslot.EndTime
                };

                db.Timeslots.Add(t);

                db.SaveChanges();
            }
        }
示例#13
0
        public void CreateAnnouncement(Announcement announcement)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Announcement a = new Data.Announcement()
                {
                    Event_ID    = announcement.EventID,
                    Title       = announcement.Title,
                    Content     = announcement.Content,
                    PublishDate = announcement.PublishDate
                };

                db.Announcements.Add(a);

                db.SaveChanges();
            }
        }
示例#14
0
        public void UpdateAnnouncement(Announcement announcement)
        {
            using (var db = new CC.Data.CCDB())
            {
                var a = db.Announcements.Find(announcement.ID);

                if (a == null)
                {
                    throw new ArgumentException("Announcement not found");
                }

                a.Title       = announcement.Title;
                a.Content     = announcement.Content;
                a.PublishDate = announcement.PublishDate;

                db.SaveChanges();
            }
        }
示例#15
0
        public void Schedule(int sessionId, int trackId, int timeslotId)
        {
            using (var db = new CC.Data.CCDB())
            {
                var session = db.Sessions.Find(sessionId);

                if (session == null)
                {
                    throw new Exception("Session not found");
                }

                session.Track_ID    = trackId == 0 ? (int?)null : trackId;
                session.Timeslot_ID = timeslotId == 0 ? (int?)null : timeslotId;
                session.Status      = trackId == 0 ? SubmittedSession : ApprovedSession;


                db.SaveChanges();
            }
        }
示例#16
0
        public void UpdateEvent(Event event_)
        {
            using (var db = new CC.Data.CCDB())
            {
                var defaultEvent = db.Events.Where(x => x.IsDefault).FirstOrDefault();
                if (event_.IsDefault)
                {
                    if (defaultEvent != null)
                    {
                        defaultEvent.IsDefault = false;
                    }
                }
                else
                {
                    if (defaultEvent == null)
                    {
                        event_.IsDefault = true;
                    }
                }

                var e = db.Events.Find(event_.ID);

                e.Name                        = event_.Name;
                e.Description                 = event_.Description;
                e.TwitterHashTag              = event_.TwitterHashTag;
                e.StartTime                   = event_.StartTime;
                e.EndTime                     = event_.EndTime;
                e.Location                    = event_.Location;
                e.Address1                    = event_.Address1;
                e.Address2                    = event_.Address2;
                e.City                        = event_.City;
                e.State                       = event_.State;
                e.Zip                         = event_.Zip;
                e.IsDefault                   = event_.IsDefault;
                e.IsSponsorRegistrationOpen   = event_.IsSponsorRegistrationOpen;
                e.IsSpeakerRegistrationOpen   = event_.IsSpeakerRegistrationOpen;
                e.IsAttendeeRegistrationOpen  = event_.IsAttendeeRegistrationOpen;
                e.IsVolunteerRegistrationOpen = event_.IsVolunteerRegistrationOpen;

                db.SaveChanges();
            }
        }
示例#17
0
        public void UpdateSponsor(Sponsor sponsor)
        {
            using (var db = new CC.Data.CCDB())
            {
                var s = db.Sponsors.Find(sponsor.ID);

                s.Name             = sponsor.Name;
                s.Description      = sponsor.Description;
                s.WebsiteUrl       = sponsor.WebsiteUrl;
                s.SponsorshipLevel = sponsor.SponsorshipLevel;

                // Don't update the image if one wasn't supplied.
                if (sponsor.Image != null && sponsor.Image.Length > 0)
                {
                    s.Image = sponsor.Image;
                }

                db.SaveChanges();
            }
        }
示例#18
0
 public void DeleteMyAgendaItem(int sessionid, int currentUserId)
 {
     try
     {
         using (var db = new CC.Data.CCDB())
         {
             var sessionAttendee =
                 db.SessionAttendees.First(sa => sa.Session_ID == sessionid && sa.Person_ID == currentUserId);
             if (sessionAttendee == null)
             {
                 throw new ArgumentException("Agenda item not found");
             }
             db.SessionAttendees.Remove(sessionAttendee);
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw new ArgumentException("Agenda item not found");
     }
 }
示例#19
0
        public void Rsvp(int eventId, int personId, string rsvp)
        {
            using (var db = new CC.Data.CCDB())
            {
                var ea = db.EventAttendees
                         .Where(x => x.Event_ID == eventId && x.Person_ID == personId)
                         .FirstOrDefault();

                if (ea == null)
                {
                    ea = new CC.Data.EventAttendee()
                    {
                        Event_ID = eventId, Person_ID = personId, Rsvp = rsvp
                    };
                    db.EventAttendees.Add(ea);
                }
                else
                {
                    ea.Rsvp = rsvp;
                }

                db.SaveChanges();
            }
        }
示例#20
0
        public void CreateEvent(Event event_)
        {
            using (var db = new CC.Data.CCDB())
            {
                if (event_.IsDefault)
                {
                    var defaultEvent = db.Events.Where(x => x.IsDefault).FirstOrDefault();
                    if (defaultEvent != null)
                        defaultEvent.IsDefault = false;
                }

                Data.Event e = new Data.Event();

                e.Name = event_.Name;
                e.Description = event_.Description;
                e.TwitterHashTag = event_.TwitterHashTag;
                e.StartTime = event_.StartTime;
                e.EndTime = event_.EndTime;
                e.Location = event_.Location;
                e.Address1 = event_.Address1;
                e.Address2 = event_.Address2;
                e.City = event_.City;
                e.State = event_.State;
                e.Zip = event_.Zip;
                e.IsDefault = event_.IsDefault;
                e.IsSponsorRegistrationOpen = event_.IsSponsorRegistrationOpen;
                e.IsSpeakerRegistrationOpen = event_.IsSpeakerRegistrationOpen;
                e.IsAttendeeRegistrationOpen = event_.IsAttendeeRegistrationOpen;
                e.IsVolunteerRegistrationOpen = event_.IsVolunteerRegistrationOpen;

                db.Events.Add(e);
                db.SaveChanges();
            }
        }
示例#21
0
        public void UpdateSponsor(Sponsor sponsor)
        {
            using (var db = new CC.Data.CCDB())
            {
                var s = db.Sponsors.Find(sponsor.ID);

                s.Name = sponsor.Name;
                s.Description = sponsor.Description;
                s.WebsiteUrl = sponsor.WebsiteUrl;
                s.SponsorshipLevel = sponsor.SponsorshipLevel;
                //s.ImageUrl = sponsor.ImageUrl;
                s.Image = sponsor.Image;

                db.SaveChanges();
            }
        }
示例#22
0
        public void DeleteAnnouncement(int id)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Announcement announcement = (from a in db.Announcements where a.ID == id select a).FirstOrDefault();

                db.Announcements.Remove(announcement);

                db.SaveChanges();
            }
        }
示例#23
0
        public void UpdateTimeslot(Timeslot timeslot)
        {
            //ToDo: Add error handling here. Brian Hall had an unhandled exception when he tried to submit a timeslot that was a past date-time.
            using (var db = new CC.Data.CCDB())
            {
                var t = db.Timeslots.Find(timeslot.ID);

                t.Name = timeslot.Name;
                t.StartTime = timeslot.StartTime;
                t.EndTime = timeslot.EndTime;

                db.SaveChanges();
            }
        }
示例#24
0
        public void DeleteMyAgendaItem(int sessionid, int currentUserId)
        {
            try
            {
                using (var db = new CC.Data.CCDB())
                {
                    var sessionAttendee =
                        db.SessionAttendees.First(sa => sa.Session_ID == sessionid && sa.Person_ID == currentUserId);
                    if (sessionAttendee == null)
                    {
                        throw new ArgumentException("Agenda item not found");
                    }
                    db.SessionAttendees.Remove(sessionAttendee);
                    db.SaveChanges();

                }
            }
            catch (Exception)
            {
                throw new ArgumentException("Agenda item not found");
            }
        }
示例#25
0
        public void DeleteSponsor(int id)
        {
            using (var db = new CC.Data.CCDB())
            {
                var s = db.Sponsors.Find(id);

                db.Sponsors.Remove(s);

                db.SaveChanges();
            }
        }
示例#26
0
        public void UpdateTrack(Track track)
        {
            using (var db = new CC.Data.CCDB())
            {
                var t = db.Tracks.Find(track.ID);

                t.Name = track.Name;
                t.Description = track.Description;

                db.SaveChanges();
            }
        }
示例#27
0
        public void DeleteTimeslot(int id)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Timeslot Timeslot = (from t in db.Timeslots.Include("Sessions")
                                          where t.ID == id
                                          select t).FirstOrDefault();

                if (Timeslot.Sessions.Count > 0)
                    throw new Exception("Can't delete a Timeslot that contains sessions!");

                db.Timeslots.Remove(Timeslot);

                db.SaveChanges();
            }
        }
示例#28
0
        public void CreateAnnouncement(Announcement announcement)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Announcement a = new Data.Announcement()
                {
                    Event_ID = announcement.EventID,
                    Title = announcement.Title,
                    Content = announcement.Content,
                    PublishDate = announcement.PublishDate
                };

                db.Announcements.Add(a);

                db.SaveChanges();
            }
        }
示例#29
0
        public void DeleteTrack(int id)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Track track = (from t in db.Tracks.Include("Sessions") where t.ID == id select t).FirstOrDefault();

                if (track.Sessions.Count > 0)
                    throw new Exception("Can't delete a track that contains sessions!");

                db.Tracks.Remove(track);

                db.SaveChanges();
            }
        }
示例#30
0
        public void CreateSponsor(Sponsor sponsor)
        {
            using (var db = new CC.Data.CCDB())
            {
                db.Sponsors.Add(sponsor.Map());

                db.SaveChanges();
            }
        }
示例#31
0
        public void CreateTrack(Track track)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Track t = new Data.Track()
                {
                    Event_ID = track.EventID,
                    Name = track.Name,
                    Description = track.Description
                };

                db.Tracks.Add(t);

                db.SaveChanges();
            }
        }
示例#32
0
        public void AttendSession(int personId, int sessionId)
        {
            using (var db = new CC.Data.CCDB())
            {

                // 1. delete old one
                Data.Session newSession = db.Sessions.Find(sessionId);
                if (newSession == null) throw new Exception("Session not found");

                var oldSession = (from sa in db.SessionAttendees.Include("Session.Timeslot")
                                  where sa.Person_ID == personId && sa.Session.ID == sessionId
                                  select sa).SingleOrDefault();

                //if (oldSession != null)
                //    db.SessionAttendees.Remove(oldSession);

                if (oldSession == null)
                    // 2. insert new one
                    db.SessionAttendees.Add(new CC.Data.SessionAttendee() { Person_ID = personId, Session_ID = sessionId, Comment = string.Empty, SessionRating = 0, SpeakerRating = 0 });

                db.SaveChanges();
            }
        }
示例#33
0
        public void Rsvp(int eventId, int personId, string rsvp)
        {
            using (var db = new CC.Data.CCDB())
            {
                var ea = db.EventAttendees
                    .Where(x => x.Event_ID == eventId && x.Person_ID == personId)
                    .FirstOrDefault();

                if (ea == null)
                {
                    ea = new CC.Data.EventAttendee() { Event_ID = eventId, Person_ID = personId, Rsvp = rsvp };
                    db.EventAttendees.Add(ea);
                }
                else
                {
                    ea.Rsvp = rsvp;
                }

                db.SaveChanges();
            }
        }
示例#34
0
        public void UpdateAnnouncement(Announcement announcement)
        {
            using (var db = new CC.Data.CCDB())
            {
                var a = db.Announcements.Find(announcement.ID);

                if (a == null) throw new ArgumentException("Announcement not found");

                a.Title = announcement.Title;
                a.Content = announcement.Content;
                a.PublishDate = announcement.PublishDate;

                db.SaveChanges();
            }
        }
示例#35
0
        public void Schedule(int sessionId, int trackId, int timeslotId)
        {
            using (var db = new CC.Data.CCDB())
            {
                var session = db.Sessions.Find(sessionId);

                if (session == null) throw new Exception("Session not found");

                session.Track_ID = trackId == 0 ? (int?)null : trackId;
                session.Timeslot_ID = timeslotId == 0 ? (int?)null : timeslotId;
                session.Status = trackId == 0 ? SubmittedSession : ApprovedSession;

                db.SaveChanges();
            }
        }
示例#36
0
        public void CreateTimeslot(Timeslot timeslot)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Timeslot t = new Data.Timeslot()
                {
                    Event_ID = timeslot.EventID,
                    Name = timeslot.Name,
                    StartTime = timeslot.StartTime,
                    EndTime = timeslot.EndTime
                };

                db.Timeslots.Add(t);

                db.SaveChanges();
            }
        }