using Swashbuckle.Swagger.Annotations;
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using WX.CRM.Common;
using WX.CRM.DataSynApi.Application;
namespace WX.CRM.DataSynApi.Controllers
{
///
/// 同步数据接口
///
public class DataSyncController : ApiController
{
private readonly SyncPushService _services = new SyncPushService();
///
/// 提交数据
///
///
[SwaggerOperation("Create")]
[SwaggerResponse(HttpStatusCode.Created)]
public HttpResponseMessage Post([FromBody] SYNC_PUSH_DTO dto)
{
try
{
_services.AddPushSync(dto);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(new { result = true }.ToJson(), Encoding.UTF8, "text/json")
};
}
catch (Exception ex)
{
LogHelper.Error("错误对象:" + dto.ToJson());
LogHelper.Error(ex.ToString());
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(new { result = false }.ToJson(), Encoding.UTF8, "text/json")
};
}
}
}
}