public async Task <bool> UpdatePetType(int petTypeId, string petTypeDesc) { var petType = await _petTypeService.GetPetType(petTypeId); petType.PetTypeDesc = petTypeDesc; return(await _petTypeService.UpdatePetType(petType)); }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { try { PetType editType = _petTypeService.UpdatePetType(id, petType); if (editType == null) { return(StatusCode(404, "could not find pet to edit")); } return(StatusCode(202, _petTypeService.UpdatePetType(id, petType))); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { if (id < 0 || petType.ID != id) { return(BadRequest("ID Error! Please check id, make sure they match!")); } _petTypeService.UpdatePetType(petType); return(StatusCode(500, "Pet Type" + petType.NameOfPetTypes + "has been updated.")); }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { if (id != petType.PetTypeId) { return(StatusCode(500, "Parameter ID and PetType ID don't match")); } _petTypeService.UpdatePetType(id, petType); return(Accepted()); }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { if (id < 1 || id != petType.Id) { return(BadRequest("Parameter ID and Pet Type ID does not match")); } if (petType == null) { return(StatusCode(404, "Did not find Pet Type with ID " + id)); } return(Ok(_petTypeService.UpdatePetType(petType))); }
public ActionResult <PetType> Put([FromBody] PetType petType) { try { _petTypeService.UpdatePetType(petType); return(petType); } catch (KeyNotFoundException e) { return(StatusCode(404, e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { if (id < 1 || id != petType.Id) { return(StatusCode(404, "Parameter Id and PetType Id must be the same")); } try { return(_petTypeService.UpdatePetType(petType)); } catch (Exception e) { return(StatusCode(500, "Task failed successfully")); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { var updatePetType = _petTypeService.UpdatePetType(petType); if (updatePetType == null) { return(StatusCode(404, "not found bro")); } try { return(updatePetType); } catch (Exception g) { return(StatusCode(500, "try again")); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { var updatePet = _petTypeService.UpdatePetType(petType); if (updatePet == null) { StatusCode(404, "pet was not found!"); } try { return(updatePet); } catch (Exception e) { return(StatusCode(500, "do much better plz")); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { var updatePetType = _petTypeService.UpdatePetType(petType); if (updatePetType == null) { return(StatusCode(404, "PetType Not Found")); } try { return(Ok(updatePetType)); } catch (Exception) { return(StatusCode(500, "Smth Went Wrong")); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType theUpdatedPetType) { if (id != theUpdatedPetType.PetTypeId || id == 0) { return(BadRequest("The Id's must match, and may not be 0.")); } else if (string.IsNullOrEmpty(theUpdatedPetType.PetTypeName)) { return(BadRequest("You need to enter a name for the new type.")); } else { try { return(Accepted(_petTypeService.UpdatePetType(theUpdatedPetType))); } catch (Exception e) { return(StatusCode(500, e.Message)); } } }
public ActionResult <PetType> UpdateByID(int ID, [FromBody] PetType type) { try { if (PetTypeService.GetPetTypeByID(ID) == null) { return(NotFound("No pet type with such ID found")); } PetType petTypeToAUpdate = PetTypeService.CreatePetType(type.Name); PetType updatedPetType = PetTypeService.UpdatePetType(petTypeToAUpdate, ID); if (updatedPetType == null) { return(StatusCode(500, "Error updating pet type in Database")); } return(Accepted(updatedPetType)); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType petTypeToPut) { if (id < 1) { return(StatusCode(500, "Request Failed - Pet type id is less than 1")); } if (id != petTypeToPut.PetTypeId) { return(StatusCode(500, "Request Failed - Pet type id from header and Pet type id from JSON body do not match")); } if (string.IsNullOrEmpty(petTypeToPut.Name)) { return(StatusCode(500, "No name of pet type supplied")); } PetType petTypeToUpdate = _petTypeService.UpdatePetType(petTypeToPut); if (petTypeToUpdate == null) { return(StatusCode(404, "No pet type with id " + id + " was found to update ")); } return(StatusCode(202, petTypeToUpdate)); }