12-控制器

using Yzs.Week04Car.BLL;
using Yzs.Week04Car.Entity;
using Newtonsoft.Json;
using System.IO;
public class CarHomeController : Controller
{
CarBLL bll = new CarBLL();
// GET: CarHome
public ActionResult Index()
{
return View();
}
public ActionResult Add()
{
return View();
}

public ActionResult AddImg()
{
return View();
}
public ActionResult CarList()
{
return View();
}
/// <summary>
/// 图片添加
/// </summary>
/// <param name="carImg"></param>
/// <returns></returns>
public int AddImged(CarImg carImg)
{
carImg.ImgTime = DateTime.Now;
return bll.AddImg(carImg);
}
public string GetCarImgType()
{
var dt = bll.GetCarImgType();
var json = JsonConvert.SerializeObject(dt);
return json;
}


/// <summary>
/// 添加房车信息
/// </summary>
/// <param name="car"></param>
/// <returns></returns>
public int CarAdd(Car car)
{
car.DataTable_Action_ = "Insert";
return bll.CarAdd(car);
}
/// <summary>
/// 汽车价格区间
/// </summary>
/// <returns></returns>
public string GetCarPinPai()
{
var dt = bll.GetCarPinPai();
var json = JsonConvert.SerializeObject(dt);
return json;
}
/// <summary>
/// 汽车价格区间
/// </summary>
/// <returns></returns>
public string GetCarPrice()
{
var dt = bll.GetCarPrice();
var json = JsonConvert.SerializeObject(dt);
return json;
}
/// <summary>
/// 汽车类型
/// </summary>
/// <returns></returns>
public string GetCarXingType()
{
var dt = bll.GetCarXingType();
var json = JsonConvert.SerializeObject(dt);
return json;
}
/// <summary>
/// 汽车分组
/// </summary>
/// <returns></returns>
public string GetCarGroup()
{
var dt = bll.GetCarGroup();
var json = JsonConvert.SerializeObject(dt);
return json;
}
public string Imgs()
{
HttpPostedFileBase http = Request.Files[0];
var path = Server.MapPath("" + Path.DirectorySeparatorChar + "Images" + Path.DirectorySeparatorChar + "");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
var name = http.FileName;
var newpath = Path.Combine(path, name);
http.SaveAs(newpath);
return "/Images/"+name;
}
public string Imgsed()
{
HttpPostedFileBase http = Request.Files[0];
if (http != null)
{
var path = Server.MapPath("" + Path.DirectorySeparatorChar + "Images" + Path.DirectorySeparatorChar + "");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
var name = http.FileName;
var newpath = Path.Combine(path, name);
http.SaveAs(newpath);
return "/Images/" + name;
}
else
return "0";
}


public string GetImgList(int pageindex = 1, string name = "")
{
var result = bll.GetImgList(pageindex,name);
var json = JsonConvert.SerializeObject(result);
return json;
}

public int Delete(int id)
{
return bll.Delete(id);
}

public string GetCarList(int pageindex = 1, string name = "")
{
var result = bll.GetCarList(pageindex, name);
var json = JsonConvert.SerializeObject(result);
return json;
}
}

转载于:https://www.cnblogs.com/Wangyang11/p/10003361.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值