//get all cats that are dogs public IHttpActionResult GetAll() { DogServices dogService = CreateDogServices(); var dog = dogService.GetAllDogs(); return(Ok(dog)); }
//dog service for the love of god private DogServices CreateDogServices() { var userId = Guid.Parse(User.Identity.GetUserId()); var dogServices = new DogServices(userId); return(dogServices); }
//get dogs by breed public IHttpActionResult GetBreed(string breed) { DogServices dogServices = CreateDogServices(); var dog = dogServices.GetDogsByBreed(breed); if (dog is null) { return(Ok($"Sorry! Looks like there are currently no {breed}'s in our database.")); } return(Ok(dog)); }
public IHttpActionResult GetById(int id) { DogServices dogService = CreateDogServices(); var dog = dogService.GetDogById(id); if (dog is null) { return(Ok($" Dude, there is no dog with that provided ID in our database.")); } return(Ok(dog)); }
static void Main(string[] args) { #region MyRegion //Create a Dog class with : //Name, Age, Color //Let the user input these parameters from a console application //Create a new Dog object from the inputs and write it as a json in a new file on the file system //Create a method that reads and prints in the console all the dogs from the txt file #endregion string name; int age; string color; while (true) { DogServices.CreateFolder(); DogServices.CreateFile(); Console.WriteLine("Enter dog's name:"); name = Console.ReadLine(); Console.WriteLine("Enter dog's age:"); bool parsed = int.TryParse(Console.ReadLine(), out age); if (!parsed) { Console.WriteLine("You didn't enter a number for Age. Please try again!"); continue; } Console.WriteLine("Enter dog's color:"); color = Console.ReadLine(); DogServices.Insert(new Dog(name, age, color)); Console.WriteLine("If you want to continue press: \"Enter\", otherwise: \"Exit\""); string user = Console.ReadLine(); if (user.ToLower() == "exit") { DogServices.PrintAllDogs(); break; } } Console.WriteLine("Do you want to clear the file? Y / N"); if (Console.ReadLine().ToLower() == "y") { DogServices.ClearFile(); } }