Example #1
0
 public ActionResult <PetType> Post([FromBody] PetType petType)
 {
     try
     {
         _petTypeService.AddNewPetType(petType);
         return(petType);
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
Example #2
0
 public ActionResult <PetType> Post([FromBody] PetType theNewType)
 {
     if (string.IsNullOrEmpty(theNewType.PetTypeName))
     {
         return(BadRequest("You need to enter a name to create a new Type."));
     }
     else
     {
         try
         {
             return(Created("Successfully created the following petType", _petTypeService.AddNewPetType(theNewType)));
         }
         catch (Exception e)
         {
             return(StatusCode(500, e.Message));
         }
     }
 }
Example #3
0
        public ActionResult <PetType> Post([FromBody] PetType petType)
        {
            if (string.IsNullOrEmpty(petType.NameOfPetTypes))
            {
                BadRequest("Another Error! Seriously?! Check it!");
            }
            else
            {
                try
                {
                    return(_petTypeService.AddNewPetType(petType));
                }
                catch (Exception e)
                {
                    return(StatusCode(500, e.Message));
                }
            }


            return(StatusCode(500, "Noob! You made a new Pet Type."));
        }