DongYing/DongYingAPI/Controllers/api/GetEssentialInformationCont...

51 lines
1.7 KiB
C#

using DataServer.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;
namespace DongYingAPI.Controllers.api
{
public class GetEssentialInformationController : ApiController
{
public HttpResponseMessage Get([FromBody] select_switching_name room)
{
var res = new get_essential_information();
try
{
if (!string.IsNullOrEmpty(room.name))
{
var data = new List<essential_informationData>();
var model=new essential_informationData();
model.DeviceName= room.name;
model.UnitType = "设备型号";
model.ManuFacturer = "生产厂家";
model.RatedCapacity = "额定容量";
model.NominalVoltage = "额定电压";
model.CarryDate = "投运日期";
model.CarryState = "投运状态";
data.Add(model);
res.code = 200;
res.msg = "成功";
res.data = data;
}
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;
}
}
}