Esempio n. 1
0
        public ActionResult <IEnumerable <Pet> > GetByName(string name)
        {
            IDogRepository dogRepository = new DogRepository();
            var            dogs          = dogRepository.GetByName(name);

            return(Ok(dogs));
        }
Esempio n. 2
0
        public ActionResult <IEnumerable <Pet> > GetAll()
        {
            IDogRepository dogRepository = new DogRepository();
            var            dogs          = dogRepository.GetAll();

            return(Ok(dogs));
        }
Esempio n. 3
0
        public App()
        {
            string dbPath = FileAccessHelper.GetLocalFilePath("dog3.db3");

            DogRep = new DogRepository(dbPath);

            var applicationStartPage = new FirstPage();

            //// The root page of your application
            //var content = new ContentPage {
            //	Title = "ASampleApp",
            //	Content = new StackLayout {
            //		VerticalOptions = LayoutOptions.Center,
            //		Children = {
            //			new Label {
            //				HorizontalTextAlignment = TextAlignment.Center,
            //				Text = "Welcome to Xamarin Forms!"
            //			}
            //		}
            //	}
            //};
            var myNavigationPage = new NavigationPage(applicationStartPage);

            MainPage = myNavigationPage;
        }
Esempio n. 4
0
        public async Task <IActionResult> OnGetAsync()
        {
            // Get user from session
            var user = await HttpContext.Session.GetUser();

            // Redirect to login page if user is invalid or user is an admin
            if (user?.Admin_permission != false || user.User_ID == null)
            {
                return(RedirectToPage("/Index"));
            }

            // Store user data in ViewData
            ViewData["name"]         = user.Name;
            ViewData["address"]      = user.Address;
            ViewData["zip code"]     = user.Zip_code;
            ViewData["phone number"] = user.Phone_number;
            ViewData["email"]        = user.Email;

            // Create dictionary for storing dogs and their lessons
            var dogs = new DogData();

            foreach (var dog in await DogRepository.GetDogs(user.User_ID))
            {
                // Add lessons to dog, or empty list if none were found
                var lessons = await LessonRepository.GetLessons(dog.Dog_ID);

                dogs[dog] = lessons?.ToList() ?? new List <Lesson>();
            }

            // Store dogs and their lessons in ViewData
            ViewData["dogs"] = dogs;
            return(Page());
        }
Esempio n. 5
0
        public App()
        {
            //MAKE THIS ASYNC AND PULL THIS OUT OF THE CONSTRUCTOR
            MyAzureBlobStorage   = new AzureBlobStorage();
            MyCloudBlobClient    = MyAzureBlobStorage.CreateCloudBlobClient();
            MyCloudBlobContainer = MyAzureBlobStorage.CreateCloudBlobClientAndContainer(ContainerName);

            string dbPath = FileAccessHelper.GetLocalFilePath("asa16dog6.db3");

            //USE THIS FOR LIST PAGE
            DogRep = new DogRepository(dbPath);

            //USE THIS FOR LIST PHOTO PAGE
            DogPhotoRep = new DogPhotoRepository(dbPath);

            //USE THIS FOR LIST PHOTO BASE SIXTY FOUR PAGE
            DogRepBaseSixtyFour = new DogRepositoryBaseSixtyFour(dbPath);

            DogRepBlob = new DogRepositoryBlob(dbPath);

            var applicationStartPage = new FirstPage();

            var myNavigationPage = new NavigationPage(applicationStartPage);

            MainPage = myNavigationPage;

            //Initialize Dog Photo View Page
            MyDogListMVVMPage        = new DogListMVVMPage();
            MyDogListPhotoPage       = new DogListPhotoPage();
            MyDogListPhotoBase64Page = new DogListPhotoBase64Page();
            MyDogListPhotoBlobPage   = new DogListPhotoBlobPage();
        }
Esempio n. 6
0
 // The constructor accepts an IConfiguration object as a parameter. This class comes from the ASP.NET framework and is useful for retrieving things out of the appsettings.json file like connection strings.
 public WalkersController(IConfiguration config)
 {
     _walkerRepo = new WalkerRepository(config);
     _ownerRepo  = new OwnerRepository(config);
     _dogRepo    = new DogRepository(config);
     _walkRepo   = new WalkRepository(config);
 }
Esempio n. 7
0
        public void GetAll_Returns_3_Dogs()
        {
            var underTest = new DogRepository();
            var result    = underTest.GetAll();

            Assert.Equal(3, result.Count);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome!");
            Console.WriteLine();

            Console.WriteLine("Listing all dogs:");
            Console.WriteLine();

            var dogRepo = new DogRepository();

            var allDogs = dogRepo.GetAllDogs();

            foreach (var dog in allDogs)
            {
                Console.WriteLine($"Dog Info: {dog.Name} is a {dog.Breed}! Notes: {dog.Notes}");
            }

            Console.WriteLine();

            Console.WriteLine("Listing all owners:");
            Console.WriteLine();

            var ownerRepo = new OwnerRepository();
            var allOwners = ownerRepo.getAllOwners();

            foreach (var owner in allOwners)
            {
                Console.WriteLine($"Name: {owner.Name}");
                Console.WriteLine($"Neighberhood: {owner.Neighborhood.Name}");
                Console.WriteLine($"Phone: {owner.Phone}");
                Console.WriteLine($"Address: {owner.Address}");
                Console.WriteLine();
            }

            var walkerRepo = new WalkerRepository();
            var allWalkers = walkerRepo.getAllWalkers();

            Console.WriteLine("Listing all walkers:");
            Console.WriteLine();

            foreach (var walker in allWalkers)
            {
                Console.WriteLine($"Name: {walker.Name}");
                Console.WriteLine($"Neighborhood: {walker.Neighborhood.Name}");
            }

            Console.WriteLine();

            Console.WriteLine("Listing all neighborhoods:");

            Console.WriteLine();

            var neighborhoodRepo = new NeighborhoodRepository();
            var allNeighborhoods = neighborhoodRepo.GetAllNeighborhoods();

            foreach (var neighborhood in allNeighborhoods)
            {
                Console.WriteLine($"Neighborhood: {neighborhood.Name}");
            }
        }
Esempio n. 9
0
 public Dog(IConfiguration configuration)
 {
     this.repository = new DogRepository(configuration);
     this.mapper     = new MapperConfiguration(cfg => {
         cfg.CreateMap <DataAccess.Entity.Dog, ViewModels.Dog>();
     }).CreateMapper();
 }
Esempio n. 10
0
 public DogController(IMediator mdr, IConfiguration config, DogRepository dogRepo, ShelterRepository shelterRepo)
 {
     _mdr         = mdr;
     _config      = config;
     _dogRepo     = dogRepo;
     _shelterRepo = shelterRepo;
 }
Esempio n. 11
0
        public App()
        {
            string dbPath = FileAccessHelper.GetLocalFilePath("dog16.db3");

            DogRep = new DogRepository(dbPath);

            var applicationStartPage = new FirstPage();

            //// The root page of your application
            //var content = new ContentPage {
            //	Title = "ASampleApp",
            //	Content = new StackLayout {
            //		VerticalOptions = LayoutOptions.Center,
            //		Children = {
            //			new Label {
            //				HorizontalTextAlignment = TextAlignment.Center,
            //				Text = "Welcome to Xamarin Forms!"
            //			}
            //		}
            //	}
            //};
            var myNavigationPage = new NavigationPage(applicationStartPage);

            MainPage = myNavigationPage;

            //Initialize Dog Photo View Page
            MyDogListPhotoPage = new DogListPhotoPage();

            //THIS WILL RUN EACH TIME YOU CHANGE THE DATABASE (ie. changing dbPath)
            IfDogSQLListEmptyThenFill();
        }
Esempio n. 12
0
 public MapController(IConfiguration config, ShelterRepository shelterRepo, DogRepository dogRepo, UserTypeRepository userTypeRepo)
 {
     _config       = config;
     _shelterRepo  = shelterRepo;
     _dogRepo      = dogRepo;
     _userTypeRepo = userTypeRepo;
 }
        public void TestSetup()
        {
            DogInitializeDb db = new DogInitializeDb();

            System.Data.Entity.Database.SetInitializer(db);
            Repo = new DogRepository();
        }
Esempio n. 14
0
 // The constructor accepts an IConfiguration object as a parameter. This class comes from the ASP.NET framework and is useful for retrieving things out of the appsettings.json file like connection strings.
 public OwnerController(IConfiguration config)
 {
     _ownerRepo        = new OwnerRepository(config);
     _dogRepo          = new DogRepository(config);
     _walkerRepo       = new WalkerRepository(config);
     _neighborhoodRepo = new NeighborhoodRepository(config);
 }
Esempio n. 15
0
 public DogService(DogRepository repository)
 {
     _repository = repository;
     _mapper     = new MapperConfiguration(cfg => {
         cfg.CreateMap <Dog, DogViewModel>();
         cfg.CreateMap <DogViewModel, Dog>();
     }).CreateMapper();
 }
Esempio n. 16
0
        public void FindById_Returns_Correct_Dog()
        {
            var underTest = new DogRepository();
            var result    = underTest.FindById(1);

            Assert.Equal(1, result.Id);
            Assert.Equal("Neko", result.Name);
        }
Esempio n. 17
0
        public ActionResult Post(Dog dog)
        {
            IDogRepository dogRepository = new DogRepository();

            dogRepository.Insert(dog);

            return(Created($"/{dog.Name}", dog));
        }
Esempio n. 18
0
        public App()
        {
            string dbPath = FileAccessHelper.GetLocalFilePath("people5.db3");

            DogRepo = new DogRepository(dbPath);
            // DogRepo.AddNewDog("Olive", "Black");
            // The root page of your application
            MainPage = new NavigationPage(new FirstPage());
        }
Esempio n. 19
0
        public App()
        {
            //MAKE THIS ASYNC AND PULL THIS OUT OF THE CONSTRUCTOR



            MyAzureBlobStorage   = new AzureBlobStorage();
            MyCloudBlobClient    = MyAzureBlobStorage.CreateCloudBlobClient();
            MyCloudBlobContainer = MyAzureBlobStorage.CreateCloudBlobClientAndContainer(ContainerName);



            string dbPath = FileAccessHelper.GetLocalFilePath("adog1.db3");

            //USE THIS FOR LIST AND LIST PHOTO PAGE
            DogRep = new DogRepository(dbPath);

            //USE THIS FOR LIST PHOTO PAGE

            DogPhotoRep = new DogPhotoRepository(dbPath);
            //USE THIS FOR LIST PHOTO BASE SIXTY FOUR PAGE
            DogRepBaseSixtyFour = new DogRepositoryBaseSixtyFour(dbPath);

            DogRepBlob = new DogRepositoryBlob(dbPath);

            var applicationStartPage = new FirstPage();

            //// The root page of your application
            //var content = new ContentPage {
            //	Title = "ASampleApp",
            //	Content = new StackLayout {
            //		VerticalOptions = LayoutOptions.Center,
            //		Children = {
            //			new Label {
            //				HorizontalTextAlignment = TextAlignment.Center,
            //				Text = "Welcome to Xamarin Forms!"
            //			}
            //		}
            //	}
            //};
            var myNavigationPage = new NavigationPage(applicationStartPage);

            MainPage = myNavigationPage;

            //Initialize Dog Photo View Page

            MyDogListMVVMPage        = new DogListMVVMPage();
            MyDogListPhotoPage       = new DogListPhotoPage();
            MyDogListPhotoBase64Page = new DogListPhotoBase64Page();

            MyDogListPhotoBlobPage = new DogListPhotoBlobPage();



            //THIS WILL RUN EACH TIME YOU CHANGE THE PATH OF THE DATABASE (ie. creating a new Database)
            //            IfDogSQLListEmptyThenFill();
        }
Esempio n. 20
0
 public UnitOfWork(ApplicationDbContext context, IPropertyMappingService propertyMappingService)
 {
     this.context = context;
     this.propertyMappingService = propertyMappingService;
     DogRepository            = new DogRepository(context, propertyMappingService);
     InstructorRepository     = new InstructorRepository(context);
     TaskRepository           = new  TaskRepository(context);
     TaskEngagementRepository = new TaskEngagementRepository(context);
     TrainingCourseRepository = new TrainingCourseRepository(context);
 }
Esempio n. 21
0
        public async Task <IActionResult> OnPostDogCreate([FromForm] int?id, [FromForm] string name,
                                                          [FromForm] string breed, [FromForm] DateTime birthday, [FromForm] string gender, [FromForm] string note,
                                                          [FromForm] int?course)
        {
            // Get user from session
            var user = await HttpContext.Session.GetUser();

            // Redirect to login page if user is invalid or user is a customer
            if (user?.Admin_permission != true || id == null)
            {
                return(RedirectToPage("/Index"));
            }

            // Check if customer to add dog to is valid
            var customer = await UserRepository.GetUser(id);

            if (customer == null)
            {
                return(RedirectToPage("/Index"));
            }

            // Parse input gender to enum, or return if it failed
            if (!Enum.TryParse <Gender>(gender, true, out var value))
            {
                return(RedirectToPage("/Index"));
            }

            // Create dog instance based on input
            var dog = new Dog
            {
                User_ID       = (int)id,
                Name          = name,
                Breed         = breed,
                Date_of_birth = birthday,
                Date_of_death = null,
                Gender        = value,
                Note          = note
            };

            // Save newly created dog in database and return if course wasn't specified
            await DogRepository.Save(dog);

            if (course == null)
            {
                return(await OnGetAsync(id));
            }

            // Enroll the inserted dog into the requested course
            var dogId = await DogRepository.GetDogId(dog);

            await CourseRepository.Enroll(dogId, course);

            return(await OnGetAsync(id));
        }
Esempio n. 22
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            // Get user from session
            var user = await HttpContext.Session.GetUser();

            // Redirect to login page if user is invalid or user is a customer
            if (user?.Admin_permission != true)
            {
                return(RedirectToPage("/Index"));
            }
            var customer = await UserRepository.GetUser(id);

            // Add users for searching
            var users = await UserRepository.GetUsers();

            ViewData["user search"] = users;

            // Set hasData and return if no customer was found
            ViewData["hasData"] = customer != null;
            if (customer == null)
            {
                return(Page());
            }

            // Store user data in ViewData
            ViewData["id"]           = customer.User_ID;
            ViewData["name"]         = customer.Name;
            ViewData["address"]      = customer.Address;
            ViewData["zip code"]     = customer.Zip_code;
            ViewData["phone number"] = customer.Phone_number;
            ViewData["email"]        = customer.Email;
            ViewData["note"]         = customer.Note;

            // Filter out courses that have finished
            var courses = await CourseRepository.GetCourses();

            ViewData["courses"] = courses.Where(course => course.Finish_date.CompareTo(DateTime.Today) >= 0);

            // Create dictionary for storing dogs and their courses
            var dogs = new DogData();

            foreach (var dog in await DogRepository.GetDogs(customer.User_ID))
            {
                // Add courses to dog, or empty list if none were found
                var dogCourses = await CourseRepository.GetCourseNames(dog.Dog_ID);

                dogs[dog] = dogCourses?.ToList() ?? new List <string>();
            }

            // Store dogs and their courses in ViewData
            ViewData["dogs"] = dogs;
            return(Page());
        }
Esempio n. 23
0
        public static async Task DoOp()
        {
            var da   = new DogRepository();
            var list = await da.GetBreedList();

            foreach (var s in list)
            {
                Console.ForegroundColor = Program.GetRandomColor();
                Console.WriteLine(s);
            }

            Console.ReadLine();
        }
Esempio n. 24
0
        // GET: RobsDogs
        public ActionResult Index()
        {
            var dogOwnerRepository = new DogOwnerRepository();
            var dogRepository      = new DogRepository();

            var dogOwnerService = new DogOwnerService(dogOwnerRepository);
            var dogService      = new DogService(dogRepository);

            var dogOwnerViewModelMapper = new DogOwnerViewModelMapper(dogOwnerService, dogService);
            var dogOwnerListViewModel   = dogOwnerViewModelMapper.GetAllDogOwners();

            return(View(dogOwnerListViewModel));
        }
Esempio n. 25
0
        private static void InitialiseRepositories()
        {
            var sqlConnection = ConfigurationManager.ConnectionStrings["PetAdoptionContextConnection"].ConnectionString;

            var builder = new DbContextOptionsBuilder <PetAdoptionContext>();

            builder.UseSqlServer(sqlConnection);

            var petAdoptionContext = new PetAdoptionContext(builder.Options);

            //DbInitialiser.Initialize(petAdoptionContext);

            _dogRepository = new DogRepository(petAdoptionContext); // new Context.PetAdoptionContext(null, null));
            _catRepository = new CatRepository(petAdoptionContext); // new Context.PetAdoptionContext(null, null));
        }
Esempio n. 26
0
        private static void Main(string[] args)
        {
            DogRepository repo = new DogRepository();

            repo.SetDog(new Dog(1, (decimal)12.4, (decimal)134.5));
            repo.SetDog(new Dog(2));
            repo.GetDogs();
            repo.GetDog(1);

            string s1 = repo.GetTitle("title", "subtitle", "author") +
                        repo.CountHowMuchYouMustSpendMoneyToBeHappy((decimal)12.4,
                                                                    (decimal)134.5, (decimal)12.4);
            string s2 = repo.GetTitle("title", "subtitle", "author") +
                        repo.CountHowMuchYouMustSpendMoneyToBeFine((decimal)12.4,
                                                                   (decimal)134.5, (decimal)12.4);

            Console.WriteLine(s1 + " vs " + s2);
            Console.ReadKey();
        }
        public void when_creating_a_dog()
        {
            // TODO: Use a registry to do this.
            new DogMapper().RegisterClassMaps();
            new AggregateRootMapper().RegisterClassMaps();

            var dog = new Dog()
                          {
                              Name = "Dog 1"
                          };

            var dogRepository = new DogRepository(new Repository(database),
                                                  database.GetCollection<Dog>(typeof (Dog).Name));

            dogRepository.CreateDogAggregate(dog);

            var dogQ = dogRepository.GetById(dog.Identity);
            Assert.AreNotEqual(dogQ, dog); // Just to make sure we pulled it from the db
            Assert.AreEqual(dogQ.Name, dog.Name);
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            WalkerRepository       walkerRepo       = new WalkerRepository();
            NeighborhoodRepository neighborhoodRepo = new NeighborhoodRepository();
            OwnerRepository        ownerRepo        = new OwnerRepository();
            DogRepository          dogRepo          = new DogRepository();


            Console.WriteLine("Getting All Walkers:");
            Console.WriteLine();

            List <Walker> allWalkers = walkerRepo.GetAllWalkers();


            foreach (Walker walker in allWalkers)
            {
                Console.WriteLine($"{walker.Id}.) {walker.Name} Walks dogs in  {walker.Neighborhood.Name}.");
            }

            Console.WriteLine("--------------------");
            Console.WriteLine("Show Walkers in specific neighborhood");
            Console.WriteLine();

            List <Neighborhood> allNeighborhoods = neighborhoodRepo.GetAllNeighborhoods();

            foreach (var n in allNeighborhoods)
            {
                Console.WriteLine($"{n.Id} {n.Name}");
            }

            var    userInput    = int.Parse(Console.ReadLine());
            Walker singleWalker = walkerRepo.GetWalkerByNeighborhood(userInput);

            Console.WriteLine($"---- Dog walkers in {singleWalker.Neighborhood.Name} ----");
            Console.WriteLine($"{singleWalker.Id}.) {singleWalker.Name} ");

            Console.ReadLine();
            Console.Clear();

            Console.WriteLine("---- Add a new Walker ----");
            Console.WriteLine();
            Console.WriteLine("What is their name?");
            var NewWalkerName = Console.ReadLine();

            Console.WriteLine($"What neighborhood does {NewWalkerName} work in?");
            foreach (var n in allNeighborhoods)
            {
                Console.WriteLine($"{n.Id} {n.Name}");
            }

            var    NewWalkerNeighborhoodId = int.Parse(Console.ReadLine());
            Walker NewWalker = new Walker
            {
                Name           = NewWalkerName,
                NeighborhoodId = NewWalkerNeighborhoodId
            };

            walkerRepo.AddWalker(NewWalker);

            Console.WriteLine($"{NewWalker.Name} has been added!");

            Console.ReadLine();
            Console.Clear();

            Console.WriteLine("----Showing all Owners----");
            List <OWNER> allOwners = ownerRepo.GetAlOwners();
            List <Dog>   allDogs   = dogRepo.GetAllDogs();

            foreach (var o in allOwners)
            {
                Console.WriteLine("----------------");
                Console.WriteLine($"{o.Name} lives in {o.Neighborhood.Name}");
                Console.WriteLine($"{o.Address}");
                Console.WriteLine($"{o.Phone}");
                Console.WriteLine("---- Dogs ----");
                foreach (var d in allDogs)
                {
                    if (d.OwnerId == o.Id)
                    {
                        Console.WriteLine($"{d.Name}");
                    }
                }
                Console.WriteLine();
            }

            Console.WriteLine("---- Add a new Owner ----");
            Console.WriteLine();
            Console.WriteLine("What is their name?");
            var newOwnerName = Console.ReadLine();

            Console.WriteLine($"What is {newOwnerName}'s phone number?");
            var newOwnerPhone = Console.ReadLine();

            Console.WriteLine($"What is {newOwnerName}'s Address?");
            var newOwnerAddress = Console.ReadLine();

            Console.WriteLine($"What neighborhood does {newOwnerName} live in?");
            foreach (var n in allNeighborhoods)
            {
                Console.WriteLine($"{n.Id} {n.Name}");
            }

            var   NewOwnerNeighborhoodId = int.Parse(Console.ReadLine());
            OWNER NewOwner = new OWNER
            {
                Name           = newOwnerName,
                Phone          = newOwnerPhone,
                Address        = newOwnerAddress,
                NeighborhoodId = NewOwnerNeighborhoodId
            };

            ownerRepo.AddOwner(NewOwner);


            Console.WriteLine($"{NewOwner.Name} has been added!");

            Console.ReadLine();
            Console.Clear();
            WalksRepository walksRepo = new WalksRepository();

            Console.WriteLine("Chose a dog walker");
            foreach (var walker in allWalkers)
            {
                Console.WriteLine($"{walker.Id}.) {walker.Name}");
            }
            var walkerChoice = walkerRepo.GetWalkerById(int.Parse(Console.ReadLine()));

            Console.WriteLine($"{walkerChoice.Name} will walk all of who's dogs?");
            foreach (var owner in allOwners)
            {
                Console.WriteLine($"{owner.Id}.) {owner.Name}");
            }
            var ownerChoice = ownerRepo.GetOwnerById(int.Parse(Console.ReadLine()));

            Console.WriteLine("For how long?");
            var durationChoice = int.Parse(Console.ReadLine());

            walksRepo.addWalk(walkerChoice, DateTime.Now, ownerChoice, durationChoice);

            Console.WriteLine($"{walkerChoice.Name} just walked {ownerChoice.Name}'s dogs for {durationChoice} minutes on {DateTime.Now.ToString()} ");
        }
 // The constructor accepts an IConfiguration object as a parameter. This class comes from the ASP.NET framework and is useful for retrieving things out of the appsettings.json file like connection strings.
 public DogsController(IConfiguration config)
 {
     _dogRepo = new DogRepository(config);
 }
Esempio n. 30
0
 public DogService(DogRepository repository, MapperConfig mapper)
 {
     _repository = repository;
     _mapper     = mapper;
 }
Esempio n. 31
0
 public LoginController(DogRepository dogRepository)
 {
     this.dogRepository = dogRepository;
 }