public void ActionApply(SysPageModel model) { if (ValidSave(model)) { ApplyRedirect(model.RecordID, item.ID); } }
public void ActionSaveNew(SysPageModel model) { if (ValidSave(model)) { SaveNewRedirect(model.RecordID, item.ID); } }
public void ActionSave(SysPageModel model) { if (ValidSave(model)) { SaveRedirect(); } }
private int GetMaxOrder(SysPageModel model) { return(SysPageService.Instance.CreateQuery() .Where(o => o.LangID == model.LangID && o.ParentID == model.ParentID) .Max(o => o.Order) .ToValue().ToInt(0) + 1); }
private bool ValidSave(SysPageModel model) { TryUpdateModel(item); if (item.ModuleCode == "0") { item.ModuleCode = string.Empty; } ViewBag.Data = item; ViewBag.Model = model; CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error; //kiem tra ten if (item.Name.Trim() == string.Empty) { CPViewPage.Message.ListMessage.Add("Nhập tên trang."); } if (CPViewPage.Message.ListMessage.Count == 0) { // neu code khong duoc nhap -> tu dong tao ra khi them moi if (item.Code == string.Empty) { item.Code = Data.GetCode(item.Name); } //neu di chuyen thi cap nhat lai Order if (model.RecordID > 0 && item.ParentID != model.ParentID) { item.Order = GetMaxOrder(model); } try { //save SysPageService.Instance.Save(item); // save file BuildFileCssJs(item); } catch (Exception ex) { Global.Error.Write(ex); CPViewPage.Message.ListMessage.Add(ex.Message); return(false); } return(true); } return(false); }
public void ActionIndex(SysPageModel model) { // sap xep tu dong string orderBy = AutoSort(model.Sort, "[Order]"); // tao danh sach var dbQuery = SysPageService.Instance.CreateQuery() .Where(o => o.ParentID == model.ParentID && o.LangID == model.LangID) .Take(model.PageSize) .OrderBy(orderBy) .Skip(model.PageIndex * model.PageSize); ViewBag.Data = dbQuery.ToList(); model.TotalRecord = dbQuery.TotalRecord; ViewBag.Model = model; }
public void ActionAdd(SysPageModel model) { if (model.RecordID > 0) { item = SysPageService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update } else { item = new SysPageEntity(); // khoi tao gia tri mac dinh khi insert item.ParentID = model.ParentID; item.Activity = true; item.LangID = model.LangID; item.Order = GetMaxOrder(model); } ViewBag.Data = item; ViewBag.Model = model; }