public IEnumerable <Session> GetSessions()
        {
            var auditLog = AuditLog.GetLog(Actions.Read, "Read all Sessions");

            Context.AuditLogs.Add(auditLog);
            Context.SaveChanges();
            return(Context.Sessions.OrderBy(s => s.Title).Take(100));
        }
Exemple #2
0
        public Session GetSessionById(Guid sessionId)
        {
            var auditLog = AuditLog.GetLog(Actions.Read, "Read Session by Id");

            Context.AuditLogs.Add(auditLog);
            Context.SaveChanges();
            return(Context.Sessions.Find(sessionId));
        }
        public Session AddSession(Session session)
        {
            var auditLog = AuditLog.GetLog(Actions.Create, "Create new Session");

            Context.AuditLogs.Add(auditLog);
            Context.Sessions.Add(session);
            Context.SaveChanges();
            return(session);
        }
Exemple #4
0
        public Voting AddVoting(Voting voting)
        {
            var auditLog = AuditLog.GetLog(Actions.Create, "Create new Voting");

            Context.AuditLogs.Add(auditLog);
            Context.Votings.Add(voting);
            Context.SaveChanges();
            return(voting);
        }
Exemple #5
0
        public IEnumerable <Voting> GetVotingsBySession(Guid sessionId)
        {
            var auditLog = AuditLog.GetLog(Actions.Read, "Read Votings by Session");

            Context.AuditLogs.Add(auditLog);
            Context.SaveChanges();
            return(Context.Votings
                   .OrderBy(voting => voting.Date)
                   .Where(voting => voting.SessionId.Equals(sessionId)));
        }
        public void DeleteSession(Guid sessionId)
        {
            var session = Context.Sessions.Find(sessionId);

            if (session == null)
            {
                throw new IndexOutOfRangeException();
            }
            var auditLog = AuditLog.GetLog(Actions.Delete, "Delete existing Session");

            Context.AuditLogs.Add(auditLog);
            Context.Sessions.Remove(session);
            Context.SaveChanges();
        }
        public Session UpdateSession(Guid sessionId, Session session)
        {
            var originalSession = Context.Sessions.Find(sessionId);

            if (originalSession == null)
            {
                throw new IndexOutOfRangeException();
            }
            var auditLog = AuditLog.GetLog(Actions.Update, "Update existing Session");

            Context.AuditLogs.Add(auditLog);
            originalSession.UpdateValuesFrom(session);
            Context.SaveChanges();
            return(originalSession);
        }