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 { DataServer.BLL.electrotherapy_room bll = new DataServer.BLL.electrotherapy_room(); public HttpResponseMessage Post([FromBody] select_switching_name room) { var res = new get_essential_information(); try { if (!string.IsNullOrEmpty(room.name)) { var data = new List(); var list=bll.GetModelList("").Where(x=>x.DeviceName== room.name).ToList(); foreach (var item in list) { var model1 = new essential_informationData(); model1.name = "设备名称"; model1.value = item.DeviceName; data.Add(model1); var model2 = new essential_informationData(); model2.name = "设备型号"; model2.value = item.UnitType; data.Add(model2); var model3 = new essential_informationData(); model3.name = "生产厂家"; model3.value = item.ManufactureFactory; data.Add(model3); var model4 = new essential_informationData(); model4.name = "额定容量"; model4.value = item.RatedCapacity; data.Add(model4); var model5 = new essential_informationData(); model5.name = "额定电压"; model5.value = item.NominalVoltage; data.Add(model5); var model6 = new essential_informationData(); model6.name = "投运日期"; model6.value = item.ManufactureDate; data.Add(model6); var model7 = new essential_informationData(); model7.name = "投运状态"; model7.value = item.OperationalCondition; data.Add(model7); } 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; } } }