Example #1
0
 public void AddPun(Pun pun)
 {
     var lastID = this.Puns.Max(p => p.PunID);
     pun.PunID = lastID + 1;
     this.Puns.Add(pun);
     Save();
 }
Example #2
0
 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();
     }
 }
Example #3
0
 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);
 }
Example #4
0
 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);
 }
Example #5
0
        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();
        }