首页 > 其他 > 详细

有用吗2

时间:2020-08-06 15:01:07      阅读:75      评论:0      收藏:0      [点我收藏+]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using EFDAL;
using DataModel;
using ServiceStack.Redis;

namespace EFExame_API.Controllers
{
public class WuLianWangController : ApiController
{
XueYuanClass dal = new XueYuanClass();

/// <summary>
/// 获取数据并存到redis里面
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("api/GetWuLianWang")]
public List<WuLianWangInfo> WlWinfos(string name = "")
{
//定义变量list接受返回的集合
var list = new List<WuLianWangInfo>();

//定义redis
RedisClient redis = new RedisClient("127.0.0.1");

//将Redis赋值给list
list = redis.Get<List<WuLianWangInfo>>("products");

//判断Redis是否为空或者他的个数是否为0
if (list == null || list.Count == 0)
{
list = dal.WlWInfos(name);

redis.Set("products", list);
}

return list;

}

/// <summary>
/// 删除数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("api/DeleInfo")]
public int DeletId(int id)
{
return dal.DeleInfo(id);
}

/// <summary>
/// 修改数据
/// </summary>
/// <param name="wuLianWang"></param>
/// <returns></returns>
[HttpPost]
[Route("api/UpdateInfo")]
public int UpdateInfo(WuLianWangInfo wuLianWang)
{
return dal.UpdateInfo(wuLianWang);
}

/// <summary>
/// 根据Id获取数据
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet]
[Route("api/GetId")]
public WuLianWangInfo FanTian(int Id)
{
return dal.FanTian(Id);
}

/// <summary>
/// 添加数据
/// </summary>
/// <param name="WuLian"></param>
/// <returns></returns>
[HttpPost]
[Route("api/AddInfo")]
public int AddInfo(WuLianWangInfo WuLian)
{
return dal.AddInfo(WuLian);
}

/// <summary>
/// 调用分页存储过程
/// </summary>
/// <param name="Pageindex"></param>
/// <param name="Pagesize"></param>
/// <returns></returns>
[HttpPost]
[Route("api/PageProc")]
public List<WuLianWangInfo> WPageProc(int Pageindex = 1, int Pagesize = 2)
{
return dal.WPageProc(Pageindex, Pagesize);
}
}
}

有用吗2

原文:https://www.cnblogs.com/li1999/p/13446052.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!