public async Task <IActionResult> DeleteAppRecipes(AppRecipesDeleteDto dto) { Metadata metadata = new Metadata { IsValid = false, Message = "", TotalCount = 0 }; try { var recipes = await _appRecipesServices.DeleteAppRecipes(dto); return(Ok(recipes)); } catch (Exception e) { metadata.IsValid = false; metadata.Message = e.InnerException.Message; var responseError = new ApiResponse <AppDetailQuotesGetDto>(null) { Meta = metadata }; return(Ok(responseError)); } }
public async Task <ApiResponse <bool> > DeleteAppRecipes(AppRecipesDeleteDto dto) { bool resultDto = true; Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <bool> response = new ApiResponse <bool>(resultDto); try { AppRecipes appRecipes = await GetById(dto.Id); if (appRecipes == null) { metadata.IsValid = false; metadata.Message = "Receta no No existe!!!"; response.Meta = metadata; response.Data = resultDto; return(response); } AppRecipes recipesExistInFormula = await _unitOfWork.AppRecipesRepository.GetRecipesByCodeInFormula((int)appRecipes.AppproductsId, appRecipes.Code); if (recipesExistInFormula != null) { metadata.IsValid = false; metadata.Message = "Variable esta siendo usada en la formulacion!!!"; response.Meta = metadata; response.Data = resultDto; return(response); } resultDto = await Delete(dto.Id); metadata.IsValid = true; metadata.Message = $"VAriable Eliminada de la Receta Satisfactoriamente!"; response.Meta = metadata; response.Data = resultDto; return(response); } catch (Exception ex) { metadata.IsValid = false; metadata.Message = ex.InnerException.Message; response.Meta = metadata; response.Data = resultDto; return(response); } }