예제 #1
0
        private async void DeleteButton_Click(object sender, EventArgs e)
        {
            if (!_recipesDataGridViewService.TryGetSelectedCellIndices(out _, out var rowIndex, true) ||
                !_recipesDataGridViewService.TryParseIntCell(ColumnName.Id, rowIndex, out var recipeId))
            {
                return;
            }

            var clientFullName = _recipesDataGridViewService.GetCellValue(ColumnName.ClientName, rowIndex);
            var diseaseName    = _recipesDataGridViewService.GetCellValue(ColumnName.DiseaseName, rowIndex);

            if (!MessageBoxService.ShowDeleteQuestion(
                    $"Are you sure you want to delete Recipe '{clientFullName}' - '{diseaseName}'?"))
            {
                return;
            }

            await _recipesService.DeleteByIdAsync(recipeId);

            await RefreshRecipesDataGridViewAsync();
        }