Exemplo n.º 1
0
        public async Task <IActionResult> Rtl433Json([FromBody] IDictionary <string, string> rawData)
        {
            rawData.TryGetValue("model", out string driverModel);
            rawData.TryGetValue("id", out string driverId);
            rawData.TryGetValue("time", out string time);

            var vm = new PostViewModel
            {
                DriverModel = driverModel,
                DriverId    = driverId,
                Time        = Convert.ToDateTime(time),
                Data        = rawData
                              .Where(a => a.Key != "model" && a.Key != "id" && a.Key != "time")
                              .ToDictionary(a => a.Key, a => a.Value)
            };

            var createdGuid = await _eventService.CreateAsync(await vm.ToDomainModel(_deviceService));

            return(Ok(createdGuid));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] PostViewModel eventVm)
        {
            var createdGuid = await _eventService.CreateAsync(await eventVm.ToDomainModel(_deviceService));

            return(Ok(createdGuid));
        }