Ejemplo n.º 1
0
        public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "alarmsubs")] HttpRequest req,
                                              ILogger log)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            DeleteAlarmSubscriptionModel dasm = JsonConvert.DeserializeObject <DeleteAlarmSubscriptionModel>(requestBody);

            AlarmWatch aw;

            try
            {
                aw = ParseFunctionModelToDtoModel(dasm);
            } catch (InvalidDataException e)
            {
                return(new BadRequestObjectResult(e.Message));
            } catch (EntityNotFoundException e)
            {
                return(new NotFoundObjectResult(e.Message));
            }

            _watchService.DeleteAlarmSubscriptionFromWatch(aw);

            return(new OkResult());
        }
Ejemplo n.º 2
0
        private AlarmWatch ParseFunctionModelToDtoModel(DeleteAlarmSubscriptionModel dasm)
        {
            AlarmWatch aw = _watchService.GetSubscriptionOfAlarmFromWatch(dasm.AlarmId, dasm.WatchId);

            return(aw);
        }