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

56 lines
2.1 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
{
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<essential_informationData>();
var model=new essential_informationData();
var list=bll.GetModelList("").Where(x=>x.DeviceName== room.name).ToList();
foreach (var item in list)
{
model.DeviceName = item.DeviceName;
model.UnitType = item.UnitType;
model.ManuFacturer =item.ManufactureFactory;
model.RatedCapacity = item.RatedCapacity;
model.NominalVoltage = item.NominalVoltage;
model.CarryDate = item.ManufactureDate;
model.CarryState = item.OperationalCondition;
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;
}
}
}