コード例 #1
0
        public static void SavePoll(PollEntry input, int round, int pollId, string membershipId)
        {
            IPollEntryRepository pollRepo = new EFPollEntriesRepository();
            var dbPoll = pollRepo.PollEntries.FirstOrDefault(p => p.OwnerMembershipId == membershipId && p.PollId == pollId);

            if (dbPoll == null)
            {
                dbPoll = new PollEntry();
                dbPoll.OwnerMembershipId = membershipId;
                dbPoll.PollId            = pollId;
            }

            dbPoll.Num1 = input.Num1;
            dbPoll.Num2 = input.Num2;
            dbPoll.Num3 = input.Num3;
            dbPoll.Num4 = input.Num4;
            dbPoll.Num5 = input.Num5;

            dbPoll.String1 = input.String1;
            dbPoll.String2 = input.String2;
            dbPoll.String3 = input.String3;
            dbPoll.String4 = input.String4;
            dbPoll.String5 = input.String5;

            dbPoll.Timestamp = DateTime.UtcNow;

            pollRepo.SavePollEntry(dbPoll);
        }
コード例 #2
0
        public static PollEntry LoadPoll(int pollId, string membershipId)
        {
            IPollEntryRepository pollRepo = new EFPollEntriesRepository();
            var dbPoll = pollRepo.PollEntries.FirstOrDefault(p => p.OwnerMembershipId == membershipId && p.PollId == pollId);

            if (dbPoll == null)
            {
                dbPoll        = new PollEntry();
                dbPoll.PollId = pollId;
            }
            return(dbPoll);
        }
コード例 #3
0
        public static IEnumerable <PollEntry> GetAllPollResults(int pollId)
        {
            IPollEntryRepository pollRepo = new EFPollEntriesRepository();

            return(pollRepo.PollEntries.Where(p => p.PollId == pollId));
        }