public ActionResult AddPost(ProductViewModel model) { C_Object Cmodel = new C_Object(); Cmodel.Name = model.Name; Cmodel.ParentId = model.ParentId; Cmodel.Sort = model.Sort; Cmodel.Creater = UserId; Cmodel.CreateTime = DateTime.Now; Cmodel.LastModifyTime = DateTime.Now; Cmodel.LastModifyUser = UserId; Cmodel.Status = 0; Cmodel.Type = (int)CommonEnum.TypeOfDbObject.Product; Cmodel.IsDelete = false; this._ObjectService.Insert(Cmodel); C_File imgmodel = new C_File(); imgmodel.FileName = model.Image; this._ObjectService.InsertImage(imgmodel); G_Name Gmodel = new G_Name(); Gmodel.Id = Cmodel.Id; Gmodel.Unit = model.Unit; Gmodel.Image = imgmodel.Id; this._GoodsService.InsertUnit(Gmodel); CategorySearchCriteria SearchCriteria = new CategorySearchCriteria(); SearchCriteria.ParentId = -1; SearchCriteria.Type = (int)CommonEnum.TypeOfDbObject.Classification; var attrsTypes = this._ObjectService.SearchCategory(SearchCriteria).Item1; var typelist = (from m in attrsTypes select new SelectListItem { Text = m.Name, Value = m.Id.ToString() }).ToList(); ViewBag.shopType = typelist; ViewBag.msg = "添加成功"; return(View(model)); }
public ActionResult EditPost(ProductViewModel model) { var Cmodel = this._ObjectService.GetById(model.Id); Cmodel.Name = model.Name; Cmodel.ParentId = model.ParentId; Cmodel.Sort = model.Sort; Cmodel.LastModifyTime = DateTime.Now; Cmodel.LastModifyUser = UserId; this._ObjectService.Update(Cmodel); C_File imgmodel = this._ObjectService.GetImageById(Cmodel.G_Name.Image); imgmodel.FileName = model.Image; imgmodel.Id = Cmodel.G_Name.Image; this._ObjectService.UpdateImage(imgmodel); G_Name Gmodel = this._GoodsService.GetById(Cmodel.Id); Gmodel.Unit = model.Unit; Gmodel.Image = imgmodel.Id; this._GoodsService.UpdateUnit(Gmodel); CategorySearchCriteria SearchCriteria = new CategorySearchCriteria(); SearchCriteria.ParentId = -1; SearchCriteria.Type = (int)CommonEnum.TypeOfDbObject.Classification; var attrsTypes = this._ObjectService.SearchCategory(SearchCriteria).Item1; var typelist = (from m in attrsTypes select new SelectListItem { Text = m.Name, Value = m.Id.ToString() }).ToList(); ViewBag.shopType = typelist; this._ObjectService.Update(Cmodel); ViewBag.msg = "修改成功"; return(View(model)); }