public ActionResult <Pet> Post([FromBody] Pet newPet)
 {
     try
     {
         return(StatusCode(201, _petService.CreateNewPet(newPet)));
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
Exemple #2
0
 public void CreateNewPet()
 {
     Console.WriteLine("You chose: Create a new Pet");
     Pet newPet = new Pet()
     {
         Name          = AskQuestion("Type Name Please:"),
         Type          = AskQuestion("Type Type Please:"),
         Color         = AskQuestion("Type Color Please:"),
         Birthdate     = AskForDate("Type pets birthdate:"),
         Solddate      = AskForDate("Type sold date"),
         PreviousOwner = AskQuestion("Type Name of former owner Please:"),
         Price         = Convert.ToDouble(AskQuestion("Type in prize please:"))
     };
     bool success = _petService.CreateNewPet(newPet);
 }
Exemple #3
0
        private Pet MakeNewPet()
        {
            Console.WriteLine("Create new Pet ");
            var name  = AskStringQuestion("Name: ");
            var type  = AskStringQuestion("Type: ");
            var color = AskStringQuestion("Color: ");

            Console.Write("Birthday: ");
            DateTime birthday = AskDateQuestion();

            Console.Write("Sold Date: ");
            DateTime soldDate = AskDateQuestion();
            var      owner    = AskStringQuestion("Previous Owner: ");

            Console.Write("Price: ");
            Double price = AskDoubleQuestion();

            return(_petService.CreateNewPet(name, type, birthday, soldDate, color, price, owner));
        }