Example #1
0
        public ValveResponseModel Update(UpdateValveRequestModel requestModel)
        {
            Valve valveItem = ModelBinder.Instance.ConvertToValve(requestModel);

            valveItem = _valveService.Update(valveItem);
            ValveResponseModel resultModel = ModelBinder.Instance.ConvertToValveResponseModel(valveItem);

            return(resultModel);
        }
Example #2
0
        public ActionResult Open(long valveId)
        {
            Valve     valveDto  = _valveService.Get(valveId);
            Raspberry raspberry = raspberryService.Get(valveDto.RaspberryId);
            string    ip        = raspberry.IPAddress;

            if (string.IsNullOrWhiteSpace(ip))
            {
                throw new Exception(" IP address of Valve can not found!");
            }

            string url = $"http://{ip}/{valveDto.EnablePin}";

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine($"\n\n\n\n{raspberry.IPAddress} valve:{valveDto.RaspberryId} opening\n{url}\n\n\n");
            Console.ForegroundColor = ConsoleColor.White;
            valveDto.IsOpen         = true;
            _valveService.Update(valveDto);

            Get(url);
            return(Ok(200));
        }