public void AddPun(Pun pun) { var lastID = this.Puns.Max(p => p.PunID); pun.PunID = lastID + 1; this.Puns.Add(pun); Save(); }
public void UpdatePun(Pun pun) { var found = this.Puns.SingleOrDefault(p => p.PunID == pun.PunID); if (found != null) { this.Puns.Remove(found); this.Puns.Add(pun); Save(); } }
private static void EnterPun() { Console.WriteLine("---------------"); Console.Write("Name of pun? "); var name = Console.ReadLine(); Console.Write("Pun? "); var joke = Console.ReadLine(); var pun = new Pun { Title = name, Joke = joke }; _service.AddPun(pun); }
private static void EditPun(int index) { Console.WriteLine("---------------"); Console.Write("Name of pun? "); var name = Console.ReadLine(); Console.Write("Pun? "); var joke = Console.ReadLine(); var pun = new Pun { PunID = index, Title = name, Joke = joke }; _service.UpdatePun(pun); }
private void SeedPuns() { var pun = new Pun { PunID = 1, Title = "Lazy Bike", Joke = "Why can't a bike stand up on its own? It's two tired!" }; this.Puns.Add(pun); Save(); }