using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace LC.UI.Controllers
{
using Entity;
using Newtonsoft.Json;
public class AddressesController : Controller
{
// GET: Addresses
public ActionResult Index()
{
return View();
}
/// <summary>
/// 新增
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
[HttpPost]
public int Add(Addresses a)
{
var json = Client.GetApi("post","Add",a);
var result = Convert.ToInt32(json);
return result;
}
/// <summary>
/// 修改
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
[HttpPost]
public int Update(Addresses a)
{
var json = Client.GetApi("post", "Update", a);
var result = Convert.ToInt32(json);
return result;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpPost]
public int Delete(int Id)
{
var json = Client.GetApi("post", "Delete?Id="+Id);
var result = Convert.ToInt32(json);
return result;
}
/// <summary>
/// 根据Id获取
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpPost]
public string QueryById(int Id)
{
var json = Client.GetApi("post", "QueryById?Id=" + Id);
var result =JsonConvert.DeserializeObject<Addresses>(json);
return JsonConvert.SerializeObject(result);
}
/// <summary>
/// 获取数据
/// </summary>
/// <returns></returns>
[HttpPost]
public string Query()
{
var json = Client.GetApi("post", "Query");
var result = JsonConvert.DeserializeObject<List<Addresses>>(json);
return JsonConvert.SerializeObject(result);
}
/// <summary>
/// 获取数据
/// </summary>
/// <returns></returns>
[HttpPost]
public string GetRegion(int PId)
{
var json = Client.GetApi("post", "GetRegion?PId="+PId);
var result = JsonConvert.DeserializeObject<List<Region>>(json);
return JsonConvert.SerializeObject(result);
}
}
}