protected virtual CustomPageModel PreparePageModel(CustomPage page) { if (page == null) { throw new ArgumentNullException("custompage"); } var model = new CustomPageModel { Id = page.Id, SystemName = page.GetSystemName(), Name = page.Name, BodyHtml = page.Template.BodyHtml, MetaKeywords = page.MetaKeywords, MetaDescription = page.MetaDescription, MetaTitle = page.MetaTitle, TemplateId = page.TemplateId, IncludeInTopMenu = page.IncludeInTopMenu, IncludeInFooterColumn1 = page.IncludeInFooterColumn1, IncludeInFooterColumn2 = page.IncludeInFooterColumn2, IncludeInFooterColumn3 = page.IncludeInFooterColumn3, IncludeInFooterMenu = page.IncludeInFooterMenu, IsSystemDefined = page.IsSystemDefined, IsActive = page.IsActive, PermissionOriented = page.PermissionOriented }; return(model); }
public List <DST_DICT> GetDictByClass(string dictClass, CustomPageModel pageModel) { int totalNum = 0; int totalPage = 0; List <DST_DICT> result = this.sqlSugarClient.Queryable <DST_DICT>().Where(x => x.DICT_CLASS.Equals(dictClass)).ToPageList(pageModel.PageIndex, pageModel.PageSize, ref totalNum, ref totalPage); return(result); }
public ActionResult Edit(int id) { if (!_permissionService.Authorize("ManageCustomPages")) { return(AccessDeniedView()); } if (id == 0) { throw new Exception("custom Page Id Missing"); } var model = new CustomPageModel(); var custompage = _customPageService.GetCustomPageById(id); if (custompage != null) { model = custompage.ToModel(); model.Url = Url.RouteUrl("CustomPage", new { name = custompage.GetSystemName() }, "http"); var templateModel = custompage.Template?.ToModel(); if (custompage.Template != null) { foreach (var dt in custompage.Template.Tokens) { var dtModel = dt.ToModel(); templateModel.dataTokens.Add(dtModel); } model.template = templateModel; } // Load Available Templates model.AvailableTemplates.Add(new SelectListItem { Text = "-- Select Template --", Value = "0" }); foreach (var t in _templateService.GetAllTemplates()) { model.AvailableTemplates.Add(new SelectListItem { Text = t.Name, Value = t.Id.ToString() }); } if (model.TemplateId > 0) { foreach (var item in model.AvailableTemplates.Where(ss => ss.Value == model.TemplateId.ToString())) { item.Selected = true; } model.AvailableTemplates.First().Selected = false; } } return(View(model)); }
/// <summary> /// 查询列表,返回分页结果 /// </summary> /// <param name="data">查询条件</param> /// <param name="pageModel">分页实体</param> /// <returns>返回结果</returns> public List <DST_PATIENT_INFO> GetPageListByCondition(DST_PATIENT_INFO data, CustomPageModel pageModel) { int totalNum = 0; int totalPage = 1; string sql = string.Format(@"SELECT M.* FROM DST_PATIENT_INFO M WHERE 1=1"); if (!string.IsNullOrEmpty(data.SLIDE_ID)) { sql += string.Format(" AND M.SLIDE_ID like '%{0}%'", data.SLIDE_ID); } if (!string.IsNullOrEmpty(data.NAME)) { sql += string.Format(" AND M.name like '%{0}%'", data.NAME); } if (data.SAMPLING_DATE != null && data.SAMPLING_DATE.Value != DateTime.MinValue) { sql += string.Format(" AND date(M.SAMPLING_DATE) = '{0}'", data.SAMPLING_DATE.Value.ToString("yyyy-MM-dd")); } if (!string.IsNullOrEmpty(data.ITEM_NAME)) { sql += string.Format(" AND M.ITEM_NAME='{0}'", data.ITEM_NAME); } if (!string.IsNullOrEmpty(data.SCAN_RESULT)) { sql += string.Format(" AND M.SCAN_RESULT='{0}'", data.SCAN_RESULT); } if (data.SCAN_DATE_TIME != null && data.SCAN_DATE_TIME.Value != DateTime.MinValue) { sql += string.Format(" AND date(M.SCAN_DATE_TIME) = '{0}'", data.SCAN_DATE_TIME.Value.ToString("yyyy-MM-dd")); } if (null != data.MinAge) { sql += string.Format(" AND M.AGE >= {0}", data.MinAge); } if (null != data.MaxAge) { sql += string.Format(" AND M.AGE <= {0}", data.MaxAge); } ISugarQueryable <DST_PATIENT_INFO> queryable = simpleClient.AsSugarClient().SqlQueryable <DST_PATIENT_INFO>(sql); List <DST_PATIENT_INFO> tmpList = queryable.ToPageList(pageModel.PageIndex, pageModel.PageSize, ref totalNum, ref totalPage); pageModel.TotalNum = totalNum; pageModel.TotalPage = totalPage; return(tmpList); }
public ActionResult Contact() { var model = new CustomPageModel(); var customPage = _customPageService.GetCustomPageByName("Contact"); if (customPage != null) { model.BodyHtml = customPage.Template.BodyHtml; model.Name = customPage.Name; model.Id = customPage.Id; model.TemplateId = customPage.TemplateId; } foreach (var dt in _templateService.GetAllDataTokensByTemplate(model.TemplateId).Where(x => x.IsActive).ToList()) { model.BodyHtml = EF.Services.CodeHelper.Replace(model.BodyHtml.ToString(), "[" + dt.SystemName + "]", dt.Value, StringComparison.InvariantCulture); } return(View(model)); }
public ActionResult Create() { if (!_permissionService.Authorize("ManageCustomPages")) { return(AccessDeniedView()); } var model = new CustomPageModel(); // Load Available Templates model.AvailableTemplates.Add(new SelectListItem { Text = "-- Select Template --", Value = "0" }); foreach (var t in _templateService.GetAllTemplates()) { model.AvailableTemplates.Add(new SelectListItem { Text = t.Name, Value = t.Id.ToString() }); } return(View(model)); }
public ActionResult PageDetails(int id) { var page = _customPageService.GetCustomPageById(id); if (page == null) { return(null); } if (!page.IsActive) { return(null); } var model = new CustomPageModel(); model = PreparePageModel(page); if (model == null) { return(RedirectToRoute("Root")); } //template var template = _templateService.GetTemplateById(model.TemplateId); if (template == null) { template = _templateService.GetAllTemplates(true).FirstOrDefault(); } if (template == null) { throw new Exception("No default template could be loaded"); } return(View(model)); }
/// <summary> /// 库存管理 查询 /// </summary> /// <param name="patInfo"></param> /// <returns></returns> public List <DST_PATIENT_INFO> GetListByConditionInArchives(DST_PATIENT_INFO patInfo, CustomPageModel pageModel) { string sql = "select * from DST_PATIENT_INFO where 1 = 1 "; if (!string.IsNullOrWhiteSpace(patInfo.SLIDE_ID)) { sql += $" and SLIDE_ID like '%{patInfo.SLIDE_ID}%'"; } if (!string.IsNullOrWhiteSpace(patInfo.NAME)) { sql += $" and NAME like '%{patInfo.NAME}%'"; } if (patInfo.LEND_OUT_DATE.HasValue && patInfo.LEND_OUT_DATE.Value != DateTime.MinValue) { sql += $" and date(LEND_OUT_DATE) = '{patInfo.LEND_OUT_DATE:yyyy-MM-dd}'"; } if (patInfo.GIVE_BACK_DATE.HasValue && patInfo.GIVE_BACK_DATE.Value != DateTime.MinValue) { sql += $" and date(GIVE_BACK_DATE) = '{patInfo.GIVE_BACK_DATE:yyyy-MM-dd}'"; } if (!string.IsNullOrWhiteSpace(patInfo.ITEM_NAME) && !patInfo.ITEM_NAME.Contains("请选择")) { sql += $" and ITEM_NAME like '%{patInfo.ITEM_NAME}%'"; } if (patInfo.SAMPLING_DATE.HasValue && patInfo.SAMPLING_DATE.Value != DateTime.MinValue) { sql += $" and date(SAMPLING_DATE) = '{patInfo.SAMPLING_DATE.Value:yyyy-MM-dd}'"; } if (patInfo.LEND_OUT != -1) // 借出 -1 表示都要 { sql += $" and LEND_OUT = {patInfo.LEND_OUT}"; } if (patInfo.GIVE_BACK != -1) // 归还 -1 表示全要 { sql += $" and GIVE_BACK = {patInfo.GIVE_BACK}"; } int totalNum = 0; int totalPage = 0; var result = this.sqlSugarClient.SqlQueryable <DST_PATIENT_INFO>(sql).ToPageList(pageModel.PageIndex, pageModel.PageSize, ref totalNum, ref totalPage); pageModel.TotalNum = totalNum; pageModel.TotalPage = totalPage; return(result); }
public ActionResult Create(CustomPageModel model) { if (!_permissionService.Authorize("ManageCustomPages")) { return(AccessDeniedView()); } var user = _userContext.CurrentUser; // Check for duplicate pages, if any var page = _customPageService.GetCustomPageByName(model.Name); if (page != null) { ModelState.AddModelError("Name", "A Custom Page with the same name already exists. Please choose a different name."); } if (ModelState.IsValid) { var custom = new CustomPage(); custom.Name = model.Name; custom.TemplateId = model.TemplateId; custom.Template = _templateService.GetTemplateById(model.TemplateId); custom.IsActive = model.IsActive; custom.ModifiedOn = DateTime.Now; custom.CreatedOn = DateTime.Now; custom.Url = model.Url; custom.UserId = user.Id; custom.IsSystemDefined = false; custom.PermissionOriented = model.PermissionOriented; custom.PermissionRecordId = model.PermissionRecordId; custom.DisplayOrder = model.DisplayOrder; custom.IncludeInFooterColumn1 = model.IncludeInFooterColumn1; custom.IncludeInFooterColumn2 = model.IncludeInFooterColumn2; custom.IncludeInFooterColumn3 = model.IncludeInFooterColumn3; custom.IncludeInTopMenu = model.IncludeInTopMenu; custom.IncludeInFooterMenu = model.IncludeInFooterMenu; custom.MetaDescription = model.MetaDescription; custom.MetaKeywords = model.MetaKeywords; custom.MetaTitle = model.MetaTitle; custom.PermissionOriented = false; custom.PermissionRecordId = _permissionService.GetAllPermissions().FirstOrDefault() != null // ReSharper disable once PossibleNullReferenceException ? _permissionService.GetAllPermissions().FirstOrDefault().Id : 0; custom.PermissionRecord = _permissionService.GetAllPermissions().FirstOrDefault(); _customPageService.Insert(custom); // Save URL Record model.SystemName = custom.ValidateSystemName(model.SystemName, model.Name, true); _urlService.SaveSlug(custom, model.SystemName); } else { // Load Available Templates model.AvailableTemplates.Add(new SelectListItem { Text = "-- Select Template --", Value = "0" }); foreach (var t in _templateService.GetAllTemplates()) { model.AvailableTemplates.Add(new SelectListItem { Text = t.Name, Value = t.Id.ToString() }); } return(View(model)); } SuccessNotification("Page created successfully."); return(RedirectToAction("List")); }
public ActionResult Edit(CustomPageModel model) { if (!_permissionService.Authorize("ManageCustomPages")) { return(AccessDeniedView()); } var user = _userContext.CurrentUser; // Check for duplicate pages, if any var _page = _customPageService.GetCustomPageByName(model.Name); if (_page != null && _page.Id != model.Id) { ModelState.AddModelError("Name", "A Custom Page with the same name already exists. Please choose a different name."); } if (ModelState.IsValid) { var custom = _customPageService.GetCustomPageById(model.Id); if (custom != null) { custom.Name = model.Name; custom.TemplateId = model.TemplateId; custom.Template = _templateService.GetTemplateById(model.TemplateId); if (!custom.IsSystemDefined) { custom.IsActive = model.IsActive; custom.IsSystemDefined = model.IsSystemDefined; } custom.ModifiedOn = DateTime.Now; custom.Url = Url.RouteUrl("CustomPage", new { name = custom.GetSystemName() }); custom.SystemName = custom.GetSystemName(); custom.UserId = user.Id; custom.PermissionOriented = model.PermissionOriented; custom.PermissionRecordId = model.PermissionRecordId; custom.DisplayOrder = model.DisplayOrder; custom.IncludeInFooterColumn1 = model.IncludeInFooterColumn1; custom.IncludeInFooterColumn2 = model.IncludeInFooterColumn2; custom.IncludeInFooterColumn3 = model.IncludeInFooterColumn3; custom.IncludeInTopMenu = model.IncludeInTopMenu; custom.IncludeInFooterMenu = model.IncludeInFooterMenu; custom.MetaDescription = model.MetaDescription; custom.MetaKeywords = model.MetaKeywords; custom.MetaTitle = model.MetaTitle; _customPageService.Update(custom); if (!custom.IsSystemDefined) { model.SystemName = custom.ValidateSystemName(model.SystemName, model.Name, true); _urlService.SaveSlug(custom, model.SystemName); } } } else { model.AvailableTemplates.Add(new SelectListItem { Text = "-- Select Template --", Value = "0" }); foreach (var t in _templateService.GetAllTemplates()) { model.AvailableTemplates.Add(new SelectListItem { Text = t.Name, Value = t.Id.ToString() }); } return(View(model)); } SuccessNotification("Page saved successfully."); return(RedirectToAction("List")); }
public static CustomPage ToEntity(this CustomPageModel model, CustomPage destination) { return(model.MapTo(destination)); }
public static CustomPage ToEntity(this CustomPageModel model) { return(model.MapTo <CustomPageModel, CustomPage>()); }
public List <DST_DICT> GetDictByClassAndName(string dictClass, string dictName, CustomPageModel pageModel) { int totalNum = 0; int totalPage = 0; List <DST_DICT> result = this.sqlSugarClient.Queryable <DST_DICT>().Where(x => x.DICT_CLASS.Equals(dictClass)) .Where(x => string.IsNullOrEmpty(dictName) || x.DICT_NAME.Equals(dictName)) .ToPageList(pageModel.PageIndex, pageModel.PageSize, ref totalNum, ref totalPage); pageModel.TotalNum = totalNum; pageModel.TotalPage = totalPage; return(result); }