57 lines
1.7 KiB
C#
57 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
|
|
{
|
|
/// <summary>
|
|
/// 碳-碳抵消
|
|
/// </summary>
|
|
public class GetCarbonOffsetController : ApiController
|
|
{
|
|
public HttpResponseMessage Get(string date="")
|
|
{
|
|
var res = new get_carbon_offset();
|
|
try
|
|
{
|
|
if(!string.IsNullOrEmpty(date))
|
|
{
|
|
var data = new List<carbon_offsetData>();
|
|
if (date == "年")
|
|
{
|
|
var model =new carbon_offsetData();
|
|
model.CarbonOffse = 0;
|
|
data.Add(model);
|
|
}else if (date == "月")
|
|
{
|
|
var model = new carbon_offsetData();
|
|
model.CarbonOffse = 0;
|
|
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;
|
|
}
|
|
}
|
|
} |