public async Task <ApiResponse <bool> > DeleteAppIngredients(AppIngredientsDeleteDto dto) { bool resultDto = true; Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <bool> response = new ApiResponse <bool>(resultDto); try { AppIngredients appIngredients = await GetById(dto.Id); if (appIngredients == null) { metadata.IsValid = false; metadata.Message = "Ingrediente No existe!!!"; response.Meta = metadata; response.Data = resultDto; return(response); } AppRecipes recipes = await _unitOfWork.AppRecipesRepository.GetRecipesByIdIngredients(dto.Id); if (recipes != null) { metadata.IsValid = false; metadata.Message = "Ingrediente existe en la formulacion!!!"; response.Meta = metadata; response.Data = resultDto; return(response); } resultDto = await Delete(dto.Id); metadata.IsValid = true; metadata.Message = $"Ingrediente Eliminada 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); } }
public async Task <IActionResult> DeteAppIngredient(AppIngredientsDeleteDto dto) { var response = await _appIngredientsService.DeleteAppIngredients(dto); return(Ok(response)); }