public ActionResult Edit(string ID) { var model = new INFOR_CATEGORIESModel(); var entity = INFOR_CATEGORIESService.INFOR_CATEGORIESList.FirstOrDefault(t => t.ID == ID); if (null != entity) { model = new INFOR_CATEGORIESModel { ID = entity.ID, InforCategoryName = entity.InforCategoryName, DisplayOrder = entity.DisplayOrder, ParentID = entity.ParentID, ParentName = entity.ParentCategory != null ? entity.ParentCategory.InforCategoryName : "", Clevel = entity.Clevel, Status = entity.Status, Item01 = entity.Item01, Item02 = entity.Item02, Item03 = entity.Item03, Item04 = entity.Item04, Item05 = entity.Item05, }; InitParentCate(model); } return(PartialView(model)); }
public ActionResult Create() { var model = new INFOR_CATEGORIESModel(); InitParentCate(model); return(PartialView(model)); }
private void InitParentCate(INFOR_CATEGORIESModel model) { var parentModuleData = INFOR_CATEGORIESService.INFOR_CATEGORIESList.Where(t => t.ParentID == "") .Select(t => new INFOR_CATEGORIESModel { ID = t.ID, InforCategoryName = t.InforCategoryName }); foreach (var item in parentModuleData) { model.ParentCategies.Add(new SelectListItem { Text = item.InforCategoryName, Value = item.ID }); var childs = INFOR_CATEGORIESService.INFOR_CATEGORIESList.Where(t => t.ParentID == item.ID); if (childs.Count() > 0) { foreach (var citem in childs) { model.ParentCategies.Add(new SelectListItem { Text = "|-- " + citem.InforCategoryName, Value = citem.ID }); } } } }
public ActionResult Index() { base.SetDisplayBtn(); base.SetCreateBtn(); base.SetEditBtn(); base.SetDeleteBtn(); var model = new INFOR_CATEGORIESModel(); return(View(model)); }
public OperationResult Update(INFOR_CATEGORIESModel model) { var entity = INFOR_CATEGORIESList.First(t => t.ID == model.ID); entity.ID = model.ID; entity.InforCategoryName = model.InforCategoryName; entity.DisplayOrder = model.DisplayOrder; entity.ParentID = model.ParentID; entity.Clevel = model.Clevel; entity.Status = model.Status; entity.Item01 = model.Item01; entity.Item02 = model.Item02; entity.Item03 = model.Item03; entity.Item04 = model.Item04; entity.Item05 = model.Item05; INFOR_CATEGORIESRepository.Update(entity); return(new OperationResult(OperationResultType.Success, "update completed")); }
public OperationResult Insert(INFOR_CATEGORIESModel model) { var entity = new INFOR_CATEGORIES { ID = model.ID, InforCategoryName = model.InforCategoryName, DisplayOrder = model.DisplayOrder, ParentID = model.ParentID, Clevel = model.Clevel, Status = model.Status, Item01 = model.Item01, Item02 = model.Item02, Item03 = model.Item03, Item04 = model.Item04, Item05 = model.Item05, }; INFOR_CATEGORIESRepository.Insert(entity); return(new OperationResult(OperationResultType.Success, "Added successfully")); }
public ActionResult Edit(INFOR_CATEGORIESModel model) { if (ModelState.IsValid) { //this.UpdateBaseData<UpdateINFOR_CATEGORIESModel>(model); OperationResult result = INFOR_CATEGORIESService.Update(model); if (result.ResultType == OperationResultType.Success) { return(Json(result)); } else { InitParentCate(model); return(PartialView(model)); } } else { InitParentCate(model); return(PartialView(model)); } }
public ActionResult Create(INFOR_CATEGORIESModel model) { if (ModelState.IsValid) { //this.CreateBaseData<INFOR_CATEGORIESModel>(model); model.ID = CombHelper.NewComb().ToString("N"); OperationResult result = INFOR_CATEGORIESService.Insert(model); if (result.ResultType == OperationResultType.Success) { return(Json(result)); } else { InitParentCate(model); return(PartialView(model)); } } else { InitParentCate(model); return(PartialView(model)); } }