• 有用吗2


    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);
    }
    }
    }

  • 相关阅读:
    (转)Android获取手机信息
    ListView中RadioButton实现单项选择
    ListView 实现分组
    解决PopupWindow遮住输入法
    Oracle多行记录合并处理
    ubuntu install express
    图片以BLOB存储在后台数据库中,Android客户端要进行读取显示
    将图片以Blob格式存入数据库,再通过Servlet显示到界面
    httpcomponents-client-4.3.6 HttpPost的简单使用
    设置Ubuntu Mysql可以远程链接
  • 原文地址:https://www.cnblogs.com/li1999/p/13446052.html
Copyright © 2020-2023  润新知