Пример #1
0
        private async Task <bool> Eliminar()
        {
            var Imagenes = await _imagenRepository.GetWithProduct(_productoId);

            foreach (Imagen imagen in Imagenes)
            {
                if (await _imagenRepository.Delete(imagen.Id))
                {
                    File.Delete(imagen.Url);
                }
            }

            var Instrucciones = await _instruccionRepository.GetWithProduct(_productoId);

            foreach (Instruccion instruccion in Instrucciones)
            {
                await _instruccionRepository.Delete(instruccion.Id);
            }

            var Ingredientes = await _ingredienteRepository.GetWithProduct(_productoId);

            foreach (Ingrediente ingrediente in Ingredientes)
            {
                await _ingredienteRepository.Delete(ingrediente.Id);
            }

            return(await _productoRepository.Delete(_productoId));
        }
Пример #2
0
        private async void BtnEliminar_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MetroFramework.MetroMessageBox.Show(this, $"Desea eliminar la instruccion", "Advertencia", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (await _instruccionRepository.Delete(_id))
                {
                    MetroFramework.MetroMessageBox.Show(this, "Se elimino la instruccion");
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Ocurrio un problema");
                }
                await CargarInstrucciones();
            }
        }