예제 #1
0
        public ActionResult Create(CoopCateViewModel model)
        {
            ServiceResult result = new ServiceResult();
            if (ModelState.IsValid)
            {
                try
                {
                    CoopCateService.Create(model);
                    result.Message = "添加CoopCate成功!";
                    LogHelper.WriteLog("添加CoopCate成功");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加CoopCate错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }

            return Json(result);
        }
예제 #2
0
 public ActionResult Create()
 {
     var model = new CoopCateViewModel();
     ViewBag.Data_PID = Utilities.GetSelectListData(
     CoopCateService.GetALL().Where(x => x.PID.Equals(null)).OrderBy(x => x.Code).ToList(), x => x.ID, x => x.CateName, true);
     return PartialView(model);
 }
예제 #3
0
        public CoopCate Create(CoopCateViewModel model)
        {
            var entity = new CoopCate();
            entity.CateName=model.CateName;
            entity.PID=model.PID;
            entity.Code=model.Code;
            entity.Level=model.Level;
            entity.OrderIndex=model.OrderIndex;

            db.Add<CoopCate>(entity);
            db.Commit();
            return entity;
        }
예제 #4
0
        public ActionResult Edit(int ID)
        {
            var entity = CoopCateService.GetALL().Single(x => x.ID == ID);

            var model = new CoopCateViewModel()
            {
                ID = entity.ID,

                CateName = entity.CateName,

                PID = entity.PID,

                Code = entity.Code,

                Level = entity.Level,

                OrderIndex = entity.OrderIndex,

            };

            ViewBag.Data_PID = Utilities.GetSelectListData(
               CoopCateService.GetALL().Where(x => x.PID.Equals(null)).OrderBy(x => x.Code).ToList(),
               x => x.ID,
               x => x.CateName, model.PID, true);

            return PartialView(model);
        }
예제 #5
0
        public CoopCate Update(CoopCateViewModel model)
        {
            var entity = Find(model.ID);
            db.Attach<CoopCate>(entity);
            entity.CateName=model.CateName;
            entity.PID=model.PID;
            entity.Code=model.Code;
            entity.Level=model.Level;
            entity.OrderIndex=model.OrderIndex;

            db.Commit();
            return entity;
        }