public void Update(GoodsClassModel model) { if (model == null) { throw new ArgumentNullException(); } if (string.IsNullOrEmpty(model.Code)) { throw new Exception("编码无效"); } if (string.IsNullOrEmpty(model.Name)) { throw new Exception("类别名称无效"); } var dbcontext = ServiceProvider.GetDbcontext <IPurocumentDbcontext>(); //验证编码 if (dbcontext.GoodsClass.Count(c => c.Code == model.Code && c.ID != model.ID) > 0) { throw new Exception("编码无效已使用"); } var entity = dbcontext.GoodsClass.SingleOrDefault(s => s.ID == model.ID); if (entity == null) { throw new Exception("类别信息不存在"); } entity.Code = model.Code; entity.Name = model.Name; entity.Desc = model.Desc; entity.BizTypeID = model.BizTypeID; dbcontext.Update(entity); dbcontext.SaveChanges(); }
public override ResponseBase Handler(AddGoodsClassRequest request) { if (request == null) { throw new ArgumentNullException(); } if (string.IsNullOrEmpty(request.Code)) { throw new Exception("编码无效"); } var bizTypeService = ServiceProvider.GetService <IBizTypeService>(); if (!bizTypeService.ValidateBizTypeID(new int[] { request.BizTypeID })) { throw new Exception("业务类型无效"); } var model = new GoodsClassModel() { Code = request.Code, Name = request.Name, Desc = request.Desc, BizTypeID = request.BizTypeID }; var goodsClassService = ServiceProvider.GetService <IGoodsClassService>(); goodsClassService.AddGoodsClass(model); return(new ResponseBase() { Result = 1, ResultInfo = "" }); }
public void AddGoodsClass(GoodsClassModel model) { if (model == null) { throw new ArgumentNullException(); } if (string.IsNullOrEmpty(model.Name)) { throw new Exception("商品分类名称不能为空"); } if (string.IsNullOrEmpty(model.Code)) { throw new Exception("商品编码无效"); } if (CodeExists(model.Code)) { throw new Exception("商品编码无效"); } var entity = new GoodsClass() { Code = model.Code, Name = model.Name, Desc = model.Desc, Disable = false, BizTypeID = model.BizTypeID }; var dbcontext = ServiceProvider.GetDbcontext <IPurocumentDbcontext>(); dbcontext.Add(entity); dbcontext.SaveChanges(); }
//#region 前台资讯分类菜单 //public PartialViewResult InfoMenu() //{ // ViewBag.InfoClassModel = InfoClassBll.GetAll(); // return PartialView(); //} //#endregion #region 资讯信息后台管理 //后台分类主页 public ActionResult Index(int?id) { var goodstype = GoodsTypeBll.GetAll(); //全部的一级分类和二级分类 var viewModel = new GoodsClassModel { GoodsTypes = goodstype.AsEnumerable().ToList(), }; if (id != null) { viewModel.Border = (from a in BorderBll.GetAll() where a.Type_ID == id select a).ToList(); //viewModel.ICC = (ICCBll.GetAll().Single(u => u.ICC_ID == id)); } return(View(viewModel)); }