73 lines
2.8 KiB
C#
73 lines
2.8 KiB
C#
using DataService.api;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Web.Http;
|
|
using System.Web.Mvc.Html;
|
|
|
|
namespace LonglslandExhibitionCenter.Controllers.api
|
|
{
|
|
/// <summary>
|
|
/// 空调-策略编辑
|
|
/// </summary>
|
|
public class GetPolicyEditingController : ApiController
|
|
{
|
|
DataService.BLL.boot_strategy bll = new DataService.BLL.boot_strategy();
|
|
DataService.BLL.unit_list bll_unit = new DataService.BLL.unit_list();
|
|
public HttpResponseMessage Get(string name="",string value="")
|
|
{
|
|
var res = new get_policy_editing();
|
|
try
|
|
{
|
|
var adata = new List<policy_editingData>();
|
|
var bdata = new List<policy_editing>();
|
|
var cdata=new List<policy_editinglist>();
|
|
if (!string.IsNullOrEmpty(name)&&!string.IsNullOrEmpty(value))
|
|
{
|
|
var blist = bll.GetModelList(" StrategyName='" + name + "'").FirstOrDefault();
|
|
var modellist = new DataService.Model.boot_strategy();
|
|
modellist.StrategyId = blist.StrategyId;
|
|
modellist.StrategyName = name;
|
|
modellist.StrategyState= blist.StrategyState;
|
|
modellist.Reserve1 = value;
|
|
bll.Update(modellist);
|
|
var list= bll.GetModelList(" StrategyName='" + name + "'").FirstOrDefault();
|
|
var alist = bll_unit.GetModelList("");
|
|
var model = new policy_editingData();
|
|
model.PolicyName= name;
|
|
var bmodel = new policy_editinglist();
|
|
bmodel.OptionalName = list.Reserve1;
|
|
cdata.Add(bmodel);
|
|
var amodel = new policy_editing();
|
|
var aname =alist.Select(x => x.UnitName);
|
|
var bname=string.Join(",", aname);
|
|
amodel.DeviceName = bname;
|
|
amodel.list = cdata;
|
|
bdata.Add(amodel);
|
|
model.data = bdata;
|
|
adata.Add(model);
|
|
res.code = 200;
|
|
res.msg = "成功";
|
|
res.data =adata;
|
|
}
|
|
else
|
|
{
|
|
res.code = 201;
|
|
res.msg = "参数不能为空";
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
res.code = 500;
|
|
res.msg = "失败," + ex.Message;
|
|
}
|
|
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(res), Encoding.GetEncoding("UTF-8"), "application/json") };
|
|
return result;
|
|
}
|
|
}
|
|
} |