public HttpResponseMessage Delete(string carId) { var response = ""; string ownerId = carBusiness.GetCar(carId).CarOwner.User_ID; if (!isUserIdEqualToLoggedInUser(ownerId)) { var message = string.Format("Permission denied"); HttpError err = new HttpError(message); return(Request.CreateResponse(HttpStatusCode.Unauthorized, err)); } else { if (carBusiness.CarIdExists(carId)) { bool carDeleted = carBusiness.DeleteCar(carId); if (carDeleted) { response = string.Format("Car unregistered successfully!"); return(Request.CreateResponse(HttpStatusCode.OK, string.Format(response))); } else { response = string.Format("Car not found"); HttpError err = new HttpError(response); return(Request.CreateResponse(HttpStatusCode.NotFound, err)); } } else { response = string.Format("Car not found"); HttpError err = new HttpError(response); return(Request.CreateResponse(HttpStatusCode.NotFound, err)); } } }