public async Task <IActionResult> DeleteBookById(int BookId) { var msg = CreateResponse(HttpStatusCode.InternalServerError, ApiErrorProvider.GetErrorResponse(ApiErrorCodes.InternalServiceError)); try { if (!ModelState.IsValid) { msg = CreateResponse(HttpStatusCode.BadRequest, ApiErrorProvider.GetErrorResponse(ModelState)); } if (BookId <= 0) { return(CreateResponse(HttpStatusCode.NotFound, ApiErrorProvider.GetErrorResponse(ApiErrorCodes.NotFound))); } BookDomain bookInfo = await _libraryManager.DeleteBookByBookId(BookId).ConfigureAwait(false); if (bookInfo == null) { return(CreateResponse(HttpStatusCode.NotFound, ApiErrorProvider.GetErrorResponse(ApiErrorCodes.BookIdRequestIsInvalid))); } msg = CreateResponse(HttpStatusCode.OK, bookInfo); } catch (UserIdNotValidException ex) { msg = CreateResponse(HttpStatusCode.NotFound, ApiErrorProvider.GetErrorResponse(ApiErrorCodes.UserIdNotPresent)); } catch (Exception ex) { msg = CreateResponse(HttpStatusCode.InternalServerError, ApiErrorProvider.GetErrorResponse(ApiErrorCodes.InternalServiceError)); } return(msg); }