public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { if (id < 1 || id != petType.PetTypeId) { return(StatusCode(500, "Parameter ID and pet type ID must be identical")); } try { petType = _petTypesService.EditPetType(petType); if (petType == null) { return(StatusCode(404, $"Did not find pet type with ID {id}")); } else { return(StatusCode(202, petType)); } } catch (ArgumentException e) { return(StatusCode(500, e.Message)); } catch (Exception) { return(StatusCode(500, ExceptionMessageConstants.NonSpecificUIMessage)); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType value) { value.Id = id; PetType petType = _petTypeService.EditPetType(value); if (petType == null) { return(StatusCode(404, "Could not find PetType with the specified id")); } else { return(StatusCode(202, petType)); } }
public ActionResult <PetType> EditPetType(int id, [FromBody] PetType petType) { try { return(Ok(_petTypeService.EditPetType(id, petType))); } catch (InvalidDataException e) { return(BadRequest("Something went wrong with your request\n" + e.Message)); } catch (KeyNotFoundException e) { return(NotFound("Could not find requested petType\n" + e.Message)); } catch (DataBaseException e) { return(StatusCode(500, e.Message)); } }