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))) }); }
public DataTransfer.Nomination Create(string name) { var n = new Nomination { Name = name }; _lunchPollContext.Nominations.Add(n); _lunchPollContext.SaveChanges(); return(Convert(n)); }