private int WelcomeAndChooseStore() { Console.WriteLine("Welcome to Bom & Barato"); Console.WriteLine("Which store are you going to shop at? Enter the Id of the desired store"); using (FranqueadoSession s = new FranqueadoSession()) { using (var das = s.CreateDataAccessScope(false)) { IMapperFranqueado map = s.CreateMapperFranqueado(); IEnumerable <Franqueado> franchisees = map.GetAll(); if (franchisees.ToList().Count() > 0) { franchisees.ToList().ForEach(x => Console.WriteLine("{0} {1} {2}", x.Id, x.Nome, x.Morada)); int f_id; while (!int.TryParse(Console.ReadLine(), out f_id) || f_id < 0 || franchisees.ToList().Find(id => id.Id == f_id) == null) { Console.WriteLine("Invalid Franchisee ID!"); } return(f_id); } } } return(-1); }
private void ShowFranchiseesList() { using (FranqueadoSession s = new FranqueadoSession()) { using (var das = s.CreateDataAccessScope(false)) { IMapperFranqueado map = s.CreateMapperFranqueado(); IEnumerable <Franqueado> franqueados = map.GetAll(); foreach (Franqueado f in franqueados) { Console.WriteLine("\tID:{0} | NIF:{1} | Name:{2}", f.Id, f.Nif, f.Nome); } } } }