Exemple #1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddScoped <IPetRepository, PetRepository>();
     services.AddScoped <IPetService, PetService>();
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
     FakePetDatabase.InitialiseData();
 }
Exemple #2
0
        public static void Main(string[] args)
        {
            ServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IPrinter, Printer>();

            FakePetDatabase.InitialiseData();
            ////then build provider
            var      serviceProvider = serviceCollection.BuildServiceProvider();
            IPrinter printer         = serviceProvider.GetRequiredService <IPrinter>();

            printer.StartUI();
        }
Exemple #3
0
        public void CreatePet(string type, string name, DateTime birthday, DateTime soldDate, string colour,
                              string previousOwner, double price)
        {
            Pet pet1 = new Pet()
            {
                Name          = name,
                Type          = type,
                Birthday      = birthday,
                SoldDate      = soldDate,
                Colour        = colour,
                PreviousOwner = previousOwner,
                Price         = price,
            };

            FakePetDatabase.InsertInto(pet1);
        }
Exemple #4
0
        public void DeletePet(int id)
        {
            Pet petToDelete = null;

            foreach (Pet p in GetPets())
            {
                if (p.ID == id)
                {
                    petToDelete = p;
                }
            }

            if (petToDelete != null)
            {
                FakePetDatabase.DeletePet(petToDelete.ID);
            }
        }
Exemple #5
0
 public IEnumerable <Pet> GetPets()
 {
     return(FakePetDatabase.SelectAll());
 }