From 8e63bc7d7c0df6e3dccea44b3c9186e016604416 Mon Sep 17 00:00:00 2001 From: wq1234wq Date: Fri, 15 Oct 2021 12:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E5=88=99=E4=B8=8B=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IoTSharp/Controllers/RulesController.cs | 15 +++++++++------ IoTSharp/IoTSharp.csproj | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/IoTSharp/Controllers/RulesController.cs b/IoTSharp/Controllers/RulesController.cs index 8304d379..44f84807 100644 --- a/IoTSharp/Controllers/RulesController.cs +++ b/IoTSharp/Controllers/RulesController.cs @@ -164,20 +164,23 @@ namespace IoTSharp.Controllers } [HttpGet("[action]")] - public AppMessage BindDevice (ModelRuleBind m) + public async Task> BindDevice (ModelRuleBind m) { - var profile = this.GetUserProfile(); + var profile =await this.GetUserProfile(); if (m.dev != null) { m.dev.ToList().ForEach(d => { if (_context.DeviceRules.Any(c => c.RuleId == m.rule && c.DeviceId == d)) { var dr = new DeviceRule(); - - - + dr.DeviceId = d; + dr.ConfigDateTime=DateTime.Now; + dr.ConfigUser = profile.Id; + dr.RuleId = m.rule; + _context.DeviceRules.Add(dr); + _context.SaveChanges(); } }); @@ -188,7 +191,7 @@ namespace IoTSharp.Controllers // return new AppMessage { ErrType = ErrType.正常返回, Result = rule }; //} - return new AppMessage { ErrType = ErrType.找不到对象, }; + return new AppMessage { ErrType = ErrType.参数错误, ErrMessage = "请选择下发设备"}; } diff --git a/IoTSharp/IoTSharp.csproj b/IoTSharp/IoTSharp.csproj index 2d35bf8f..72331a5f 100644 --- a/IoTSharp/IoTSharp.csproj +++ b/IoTSharp/IoTSharp.csproj @@ -201,5 +201,8 @@ + + + -- GitLab