コード例 #1
0
        public async Task <ActionResult> EditRuleProperties(string deviceId, string ruleId)
        {
            EditDeviceRuleModel editModel = null;

            //empty ruleId implies that we are creating new
            if (string.IsNullOrWhiteSpace(ruleId))
            {
                bool canCreate = await _deviceRulesLogic.CanNewRuleBeCreatedForDeviceAsync(deviceId);

                if (!canCreate)
                {
                    editModel = new EditDeviceRuleModel()
                    {
                        DeviceID = deviceId
                    };
                    return(View("AllRulesAssigned", editModel));
                }
            }

            DeviceRule ruleModel = await _deviceRulesLogic.GetDeviceRuleOrDefaultAsync(deviceId, ruleId);

            Dictionary <string, List <string> > availableFields = await _deviceRulesLogic.GetAvailableFieldsForDeviceRuleAsync(ruleModel.DeviceID, ruleModel.RuleId);

            List <SelectListItem> availableDataFields  = this.ConvertStringListToSelectList(availableFields["availableDataFields"]);
            List <SelectListItem> availableOperators   = this.ConvertStringListToSelectList(availableFields["availableOperators"]);
            List <SelectListItem> availableRuleOutputs = this.ConvertStringListToSelectList(availableFields["availableRuleOutputs"]);

            editModel = CreateEditModelFromDeviceRule(ruleModel);
            editModel.AvailableDataFields  = availableDataFields;
            editModel.AvailableOperators   = availableOperators;
            editModel.AvailableRuleOutputs = availableRuleOutputs;

            return(View("EditDeviceRuleProperties", editModel));
        }
コード例 #2
0
 public async Task <HttpResponseMessage> GetAvailableFieldsForDeviceRuleAsync(string deviceId, string ruleId)
 {
     return(await GetServiceResponseAsync(async() => await _deviceRulesLogic.GetAvailableFieldsForDeviceRuleAsync(deviceId, ruleId)));
 }