API控制器

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using ZhouKaoA.Models;

namespace ZhouKaoA.Controllers
{
public class DefaultController : ApiController
{

APIFileHelp help = new APIFileHelp();

[HttpGet]
public List<Shopping> GetShopShow()
{
string sql = $"select * from Shopping";
return DBHelper.GetList<Shopping>(sql);
}

[HttpGet]
public UserInfo DengLu(string username, string pwd)
{
string sql = $"select * from UserInfo where UserNum = '{username}' and UserPwd = '{pwd}'";
return DBHelper.GetList<UserInfo>(sql).FirstOrDefault();
}

[HttpGet]
public List<OrderInfo> GetOrderShow(string username)
{
string sql = $"select * from OrderInfo as o join Shopping as s on o.ShopWid = s.ShopId where Oname = '{username}'";
return DBHelper.GetList<OrderInfo>(sql);
}

[HttpGet]
public List<OrderInfo> GetOrderShowTwo(int id)
{
string sql = $"select * from OrderInfo as o join Shopping as s on o.ShopWid = s.ShopId where Oid = {id}";
return DBHelper.GetList<OrderInfo>(sql);
}

[HttpPost]
public FileResult UpLoad()
{
return help.UpLoad();
}

[HttpGet]
public int Proc(string DelReson,string DelPicture,int OrderId)
{
int result = 0;

SqlParameter[] spa = new SqlParameter[]
{
new SqlParameter(){ ParameterName="@DelReson",SqlDbType=SqlDbType.NVarChar,SqlValue=DelReson},
new SqlParameter(){ ParameterName="@DelPicture",SqlDbType=SqlDbType.NVarChar,SqlValue=DelPicture},
new SqlParameter(){ ParameterName="@OrderId",SqlDbType=SqlDbType.Int,SqlValue=OrderId},
new SqlParameter(){ ParameterName="@Rults",SqlDbType=SqlDbType.Int,Direction = ParameterDirection.Output}
};
var list = DBHelper.Do_Proc("My_proc", spa);
result = Convert.ToInt32(spa[3].Value);
return result;
}


}
}

 

{action}

posted @ 2020-07-09 20:26  jieModels  阅读(140)  评论(0)    收藏  举报