public bool ValidateDelete( OfmDeletionQueryResult <TId> ofmDeletionQueryResult, TId id, out ObjectResult objectResult) { objectResult = null; if (ofmDeletionQueryResult.ErrorMessages.Count > 0) { // For the moment, we return 500 error message to avoid exposing too much info. // No errorMessage from lower levels are anticipated, so an exception was probably thrown _controller.ModelState.AddModelError(_shortCamelCasedControllerName, "There was an internal server error. Please contact support."); objectResult = new InternalServerErrorObjectResult(_controller.ModelState); return(false); } if (ofmDeletionQueryResult.DidEntityExist == false && ofmDeletionQueryResult.ErrorMessages.Count == 0) { _controller.ModelState.AddModelError(_shortCamelCasedControllerName, "No " + _shortCamelCasedControllerName + " found for id=" + id); objectResult = new EntityNotFoundObjectResult(_controller.ModelState); return(false); } return(true); }
public virtual async Task <OfmDeletionQueryResult <TId> > Delete(TId id) { var entityDeletionResult = await Repo.Delete(id); var ofmDeletionQueryResult = new OfmDeletionQueryResult <TId>(); ofmDeletionQueryResult.DidEntityExist = entityDeletionResult.DidEntityExist; ofmDeletionQueryResult.IsDeleted = entityDeletionResult.IsDeleted; return(ofmDeletionQueryResult); }