zoukankan      html  css  js  c++  java
  • 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;
    }
    }

  • 相关阅读:
    汇编语言(王爽) 实验九
    汇编语言(王爽)实验十
    leetcode longest common prefix(easy) /java
    leetcode container-with-most-water(medium) /java
    jdbc 驱动设置
    天上的星星都洒在我身上(mysql重装失败指南)
    leetcode palindrome number(easy) /java
    异常处理
    递归函数
    序列化模块
  • 原文地址:https://www.cnblogs.com/Wangyang11/p/10003361.html
Copyright © 2011-2022 走看看