public int AddGoodsInfo(string obj) { Models.GoodsInfo m = JsonConvert.DeserializeObject <Models.GoodsInfo>(obj); //上传图片 if (Request.Form.Files.Count > 0) { // tp://localhost:49233/Files/%E6%96%B0%E5%BB%BA%E6%96%87%E6%9C%AC%E6%96%87%E6%A1%A3.html //获取物理路径 webtootpath string path = hosting.WebRootPath + "\\Img\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var file = Request.Form.Files[0]; //拼接路径 path += $"{file.FileName}"; using (FileStream stream = new FileStream(path, FileMode.Create)) { file.CopyToAsync(stream); } m.GoodsImg = "/Img/" + file.FileName; } return(goodsBLL.AddGoodsInfo(m)); }
public int UpdateGoods([FromForm] Models.GoodsInfo model) { Models.GoodsInfo m = new Models.GoodsInfo() { Id = model.Id, GoodsName = model.GoodsName, GoodsBrand = model.GoodsBrand, TypeId = model.TypeId, GoodsRule = model.GoodsRule, SKU = model.SKU, GoodsPrices = model.GoodsPrices, PriceId = model.PId, JinHPrice = model.JinHPrice }; return(_bll.UpGoods(m)); }
public int AddGoodsInfo(Models.GoodsInfo m) { string procName = "AddGoodsInfo"; SqlParameter[] param = new SqlParameter[] { new SqlParameter { ParameterName = "@GoodsId", DbType = DbType.String, Direction = ParameterDirection.Input, Value = m.GoodsId }, new SqlParameter { ParameterName = "@GoodsName", DbType = DbType.String, Direction = ParameterDirection.Input, Value = m.GoodsName }, new SqlParameter { ParameterName = "@GoodsImg", DbType = DbType.String, Direction = ParameterDirection.Input, Value = m.GoodsImg }, new SqlParameter { ParameterName = "@GoodsPrice", DbType = DbType.Decimal, Direction = ParameterDirection.Input, Value = m.GoodsPrices }, new SqlParameter { ParameterName = "@GoodsBrand", DbType = DbType.String, Direction = ParameterDirection.Input, Value = m.GoodsBrand }, new SqlParameter { ParameterName = "@GoodsStock", DbType = DbType.Int32, Direction = ParameterDirection.Input, Value = m.GoodsStock }, new SqlParameter { ParameterName = "@TypeId", DbType = DbType.Guid, Direction = ParameterDirection.Input, Value = m.TypeId }, new SqlParameter { ParameterName = "@StockYJ", DbType = DbType.Int32, Direction = ParameterDirection.Input, Value = m.StockYJ }, new SqlParameter { ParameterName = "@UpTime", DbType = DbType.Date, Direction = ParameterDirection.Input, Value = m.UpTime }, new SqlParameter { ParameterName = "@GoodsRule", DbType = DbType.String, Direction = ParameterDirection.Input, Value = m.GoodsRule }, new SqlParameter { ParameterName = "@SKU", DbType = DbType.String, Direction = ParameterDirection.Input, Value = m.SKU }, new SqlParameter { ParameterName = "@GoodsState", DbType = DbType.Int32, Direction = ParameterDirection.Input, Value = m.GoodsState } }; return(dBHelper.ExecuteNonQueryProc(procName, param)); }
/// <summary> /// 修改商品信息 /// </summary> /// <param name="m"></param> /// <returns></returns> public int UpGoods(Models.GoodsInfo m) { return(_dal.UpGoods(m)); }