コード例 #1
0
        public Models.Ballot FindExistingBallot(string userId)
        {
            var builder = new BallotBuilder();
            var ballot  = Context.Ballots.FirstOrDefault(x => x.AspNetUserId == userId);

            return(ballot == null ? null : builder.GetModel(ballot));
        }
コード例 #2
0
        public Models.Ballot CreateBallot(string ballotName, string userId)
        {
            var builder = new BallotBuilder();
            var ballot  = new Ballot()
            {
                BallotId     = Guid.NewGuid(),
                BallotName   = ballotName,
                AspNetUserId = userId
            };

            Context.Ballots.Add(ballot);
            Context.SaveChanges();

            return(builder.GetModel(ballot));
        }