コード例 #1
0
        public async Task <IActionResult> Delete(string name)
        {
            try
            {
                await _funcManager.DeleteFunction(name);
            }
            catch (FileNotFoundException e)
            {
                return(NotFound(e.Message));
            }

            return(Ok());
        }
コード例 #2
0
        public static async Task <IReadOnlyList <int> > DeleteFunctionAsync(FunctionData function, FunctionManager functionManager, bool showPrompt = true)
        {
            AppTelemetry.Current.TrackEvent(
                TelemetryEvents.DeleteFunction,
                TelemetryProperties.Function,
                function.Name);

            var dependentFunctionNames = new HashSet <string>(functionManager.GetDependentFunctions(function));

            dependentFunctionNames.Remove(function.Name);

            if (!dependentFunctionNames.Any())
            {
                functionManager.DeleteFunction(function);
                return(new int[] { function.Id });
            }

            if (showPrompt)
            {
                var dialog = new DeleteConfirmationDialog(function.Name, dependentFunctionNames);
                ContentDialogResult result = await dialog.ShowAsync();

                if (result != ContentDialogResult.Primary)
                {
                    return(new int[0]);
                }
            }

            FunctionData[] functionsToRemove = functionManager.Functions.Where(f => dependentFunctionNames.Contains(f.Name)).ToArray();
            foreach (FunctionData dependentFunction in functionsToRemove)
            {
                functionManager.DeleteFunction(dependentFunction);
            }

            functionManager.DeleteFunction(function);

            return(functionsToRemove.Select(f => f.Id).Append(function.Id).ToList());
        }
コード例 #3
0
    public static bool DeleteFunction(int functionId)
    {
        bool result = true;

        using (FunctionManager functionManager = new FunctionManager(null))
        {
            try
            {
                functionManager.DeleteFunction(functionId);
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                result = false;
            }
        }
        return(result);
    }
コード例 #4
0
    public static bool DeleteFunction(int functionId)
    {
        bool result = true;
        using (FunctionManager functionManager = new FunctionManager(null))
        {
            try
            {
                functionManager.DeleteFunction(functionId);
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                result = false;
            }
        }
        return result;

    }