public static void edit(long id) { try { var pp = Moperson.Access.Get(id); if (pp != null) { Moperson p = new Moperson(); p.Id = id; Console.WriteLine("Type the person's new first name :"); p.first_name = Console.ReadLine(); Console.WriteLine("Type the person's new last name :"); p.last_name = Console.ReadLine(); Console.WriteLine("Type the person's new age :"); p.age = int.Parse(Console.ReadLine()); Console.WriteLine("Type the person's new dob :"); p.date_of_birth = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Type the person's new address :"); p.address = Console.ReadLine(); Moperson.Access.Edit(p); Console.WriteLine("{0} {1} successfully edited.", p.first_name, p.last_name); } else { Console.WriteLine("I am sorry, {0} is not found in db.\nWe can not edit him", id); } } catch (Exception ex) { Console.WriteLine("Oops... ! An exception occurs.\r\n{0}\r\n\r\n{1}", ex.Message, ex.StackTrace); } }
public static void add() { try { Moperson p = new Moperson(); Console.WriteLine("Type the person's first name :"); p.first_name = Console.ReadLine(); Console.WriteLine("Type the person's last name :"); p.last_name = Console.ReadLine(); Console.WriteLine("Type the person's age :"); p.age = decimal.Parse(Console.ReadLine()); Console.WriteLine("Type the person's dob :"); p.date_of_birth = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Type the person's address :"); p.address = Console.ReadLine(); Moperson.Access.Add(p); Console.WriteLine("{0} {1} successfully added to the db.", p.first_name, p.last_name); } catch (Exception ex) { Console.WriteLine("Oops... ! An exception occurs.\r\n{0}\r\n\r\n{1}", ex.Message, ex.StackTrace); } }