コード例 #1
0
        private static DataTransfer.Nomination Convert(Nomination n,
                                                       int approves        = 0,
                                                       int vetoes          = 0,
                                                       bool?approved       = null,
                                                       bool?vetoed         = null,
                                                       DateTime?approvedOn = null,
                                                       DateTime?vetoedOn   = null)
        {
            var t = n.CreatedOn.Ticks;

            return(new DataTransfer.Nomination
            {
                Id = n.NominationId,
                Name = n.Name,
                Approves = approves,
                Vetoes = vetoes,
                Approved = approved,
                Vetoed = vetoed,
                LastChanged = new DateTime(Math.Max(
                                               t,
                                               Math.Max(
                                                   approvedOn?.Ticks ?? t,
                                                   vetoedOn?.Ticks ?? t)))
            });
        }
コード例 #2
0
        public DataTransfer.Nomination Create(string name)
        {
            var n = new Nomination {
                Name = name
            };

            _lunchPollContext.Nominations.Add(n);
            _lunchPollContext.SaveChanges();
            return(Convert(n));
        }