public async Task <IActionResult> Edit(DefaultModel model, CPMenuEntity item) { ViewBag.Title = "Chỉnh sửa"; if (string.IsNullOrEmpty(model.ID) && string.IsNullOrEmpty(item.ID)) { ViewBag.Message = "Chưa chọn đối tượng đê sửa"; } else { string ID = model.ID; var _item = _service.GetByID(ID); if (_item != null) { item.ID = _item.ID; item.Code = UnicodeName.ConvertUnicodeToCode(item.Name, "-", true); item.LangID = _currentLang.ID; await _service.AddAsync(item); } ViewBag.Data = _service.GetByID(ID); } ViewBag.Root = _service.CreateQuery().FindList(true, o => string.IsNullOrEmpty(o.ParentID) && o.IsActive == true) .Where(_currentLang != null, o => o.LangID == _currentLang.ID).ToList(); ViewBag.Model = model; return(RedirectToAction("index")); }
public async Task <IActionResult> Create(DefaultModel model, CPMenuEntity item) { ViewBag.Title = "Thêm mới"; if (!string.IsNullOrEmpty(model.ID) || !string.IsNullOrEmpty(item.ID)) { return(RedirectToAction("Edit", new { model.ID })); } else { if (!item.ParentID.Equals("0")) { var root = _service.GetByID(item.ParentID); if (root != null) { item.Type = root.Type; } } item.LangID = _currentLang.ID; item.Code = UnicodeName.ConvertUnicodeToCode(item.Name, "-", true); await _service.AddAsync(item); } ViewBag.Root = _service.Find(true, o => o.ParentID.Equals("0") && o.IsActive == true) .Where(_currentLang != null, o => o.LangID == _currentLang.ID).ToList(); return(View()); }
public async Task <IActionResult> Create(DefaultModel model, CPMenuEntity item) { ViewBag.Title = "Thêm mới"; if (model.ID > 0 || item.ID > 0) { return(RedirectToAction("Edit", new { model.ID })); } else { if (item.ParentID > 0) { var root = _service.GetItemByID(item.ParentID); if (root != null) { item.Type = root.Type; } } item.LangID = _currentLang.ID; item.Code = UnicodeName.ConvertUnicodeToCode(item.Name, "-", true); await _service.SaveAsync(item); } ViewBag.Root = _service.CreateQuery().Find(o => o.ParentID == 0 && o.Activity == true) .Where(_currentLang != null, o => o.LangID == _currentLang.ID).ToList(); return(View()); }