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

  • 相关阅读:
    pyenv: python2.7: command not found The `python2.7' command exists in these Python versions: 2.7.5
    Gazebo_02_build_a_robot
    Gazebo_01_getting_start
    vscode等编辑器中报Exception has occurred: ModuleNotFoundError No module named 'requests'
    Ubuntu16.04安装Python3.8以后出现lsb_release/No LSB modules are available的错误
    C语言字符串定义(数组&指针)
    电脑软件更新管理
    VS2017自定义新建模板
    《SQL必知必会-第四版》--学习摘抄
    实体类封装数据库查询信息(工具一)
  • 原文地址:https://www.cnblogs.com/Wangyang11/p/10003361.html
Copyright © 2020-2023  润新知