Example #1
0
        public async Task <ActionResult> Delete(string source, int id)
        {
            try
            {
                GetStorageAccount();
                RuleManagement rules = new RuleManagement(connectionString);
                await rules.DeleteRule(source, id);
            }
            catch (Exception)
            {
                return(BadRequest());
            }

            return(NoContent());
        }
Example #2
0
        public static async Task <IActionResult> DeleteRule(
            [HttpTrigger(AuthorizationLevel.Function, "delete", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("DeleteDataRule: Starting");
            try
            {
                string name = req.Query["name"];
                if (string.IsNullOrEmpty(name))
                {
                    log.LogError("DeleteDataRule: error, source name is missing");
                    return(new BadRequestObjectResult("Error missing source name"));
                }

                string strId = req.Query["id"];
                int?   tmpId = strId.GetIntFromString();
                if (tmpId == null)
                {
                    log.LogError("DeleteDataRule: error, rule id name is missing");
                    return(new BadRequestObjectResult("Error missing rule id"));
                }
                int id = tmpId.GetValueOrDefault();

                string         storageAccount = Common.Helpers.Common.GetStorageKey(req);
                RuleManagement rules          = new RuleManagement(storageAccount);
                await rules.DeleteRule(name, id);
            }
            catch (Exception ex)
            {
                log.LogError($"DeleteDataRule: {ex}");
                return(new BadRequestObjectResult($"Error deleting rule: {ex}"));
            }

            log.LogInformation("DeleteDataRule: Complete");
            return(new OkObjectResult("OK"));
        }