示例#1
0
        public async Task <ActionResult> Create([FromBody] Sensor sensor)
        {
            if (sensor == null || String.IsNullOrEmpty(sensor.MicrocontrollerID))
            {
                return(new UnprocessableEntityResult());
            }

            var Mcu = await microControllerService.FindByID(sensor.MicrocontrollerID);

            if (Mcu == null)
            {
                return(new BadRequestResult());
            }


            var inserted = await sensorService.Create(sensor);

            if (inserted == null)
            {
                return(new BadRequestResult());
            }



            await microControllerService.AddEquipmentReference(inserted.MicrocontrollerID, inserted.Id);

            return(new OkObjectResult(inserted));
        }
示例#2
0
        public async Task <ActionResult <MicroController> > GetById([FromRoute] string id)
        {
            var result = await microControllerService.FindByID(id);

            if (result != null)
            {
                return(Ok(result));
            }
            return(NotFound());
        }
示例#3
0
        public async Task <ActionResult> Create([FromBody] Actuator actuator)
        {
            if (actuator == null)
            {
                return(new UnprocessableEntityResult());
            }
            var Mcu = await microControllerService.FindByID(actuator.MicrocontrollerID);

            if (Mcu == null)
            {
                return(new BadRequestResult());
            }

            var inserted = await actuatorService.Create(actuator);

            if (inserted == null)
            {
                return(new BadRequestResult());
            }

            return(new OkObjectResult(inserted));
        }