/// <summary> /// 添加或更新标准光照计划数据 /// </summary> /// <param name="data">数据</param> /// <returns></returns> public OperationResult LightPlan_0x54(LightPlan_0x54_In data) { var host = HostRepository.Entities.FirstOrDefault(m => m.RegPackage == data.RegPackage); if (host == null) { return(new OperationResult(OperationResultType.QueryNull, $"光照计划主机:{data.RegPackage}不存在")); } else { var item = DataItemDetailRepository.Entities.FirstOrDefault(m => m.QueryCoding == "LigthPlanType" && m.Index == 0); if (item == null) { return(new OperationResult(OperationResultType.QueryNull, "标准光照计划类型主键不存在")); } else { var lg = LightPlanRepository.TrackEntities.FirstOrDefault(m => m.DataItemDetail_Id == item.Id && m.Host_Id == host.Id); if (lg == null) { lg = data.MapTo <LightPlan>(); lg.CreatedTime = DateTime.Now; lg.UpdatedTime = DateTime.Now; lg.Host_Id = host.Id; lg.DataItemDetail_Id = item.Id; return(LightPlanRepository.Insert(lg) > 0 ? new OperationResult(OperationResultType.Success, $"主机:{data.RegPackage}的标准光照计划信息更新成功!") : new OperationResult(OperationResultType.NoChanged, $"主机:{data.RegPackage}的标准光照计划信息更新未发生改变")); } else { Guid Id = lg.Id; lg = data.MapTo(lg); lg.Id = Id; lg.UpdatedTime = DateTime.Now; return(LightPlanRepository.Update(lg) > 0 ? new OperationResult(OperationResultType.Success, $"主机:{data.RegPackage}的标准光照计划信息更新成功!") : new OperationResult(OperationResultType.NoChanged, $"主机:{data.RegPackage}的标准光照计划信息更新未发生改变")); } } } }
public IHttpActionResult Host_0x54([FromBody] LightPlan_0x54_In data) => Json(LightPlanService.TryCatchAction(m => { return(m.LightPlan_0x54(data)); }));