public static HtmlString GetSelectMini(this CPLangEntity currentLang, List <CPLangEntity> data) { if (data == null) { return(new HtmlString(string.Empty)); } int count = data.Count; if (count == 0) { return(new HtmlString(string.Empty)); } string html = "<div>"; for (int i = 0; i < count; i++) { var item = data[i]; if (currentLang != null && currentLang.Code == item.Code) { html += "<a href=\"javascript:void(0)\" class=\"btn btn-sm btn-success\" style=\"padding:3px\">" + item.Code.ToUpper() + "</a>"; } else { html += "<a href=\"javascript:void(0)\" onclick=\"changeLang('" + item.Code + "')\" class=\"btn btn-sm btn-dark\" style=\"padding:3px\">" + item.Code.ToUpper() + "</a>"; } } html += "</div>"; return(new HtmlString(html)); }
public ViewPage() { _templateService = new SysTemplateService(); _templateDetailsService = new SysTemplateDetailsService(); _currentLang = StartUp.CurrentLang; _pageService = new SysPageService(); }
public CPApiController(ILogs logs , IConfiguration configuration , SysTemplateDetailService templateDetailService , SysTemplateService templateService , SysTemplatePropertyService templatePropertyService , CPMenuService menuService , CPUserService userService , CPRoleService roleService , CPLangService langService , Security security) { _configuration = configuration; _logs = logs; _menu = new WebMenu(); _security = security; _templateDetailsService = templateDetailService; _templateService = templateService; _menuService = menuService; _propertyService = templatePropertyService; _userService = userService; _roleService = roleService; _langService = langService; _currentLang = StartUp.CurrentLang; }
public CPApiController(ILogs logs , IConfiguration configuration , CPMenuService menuService , CPUserService userService , CPRoleService roleService , CPLangService langService , Security security , ModLessonService lessonService , ModLessonPartService lessonPartService , ModLessonExtendService lessonExtendService , ModLessonPartAnswerService answerService , CPLoginLogService loginLogService , FileProcess fileProcess) { _configuration = configuration; _logs = logs; _menu = new WebMenu(); _security = security; _menuService = menuService; _userService = userService; _roleService = roleService; _langService = langService; _lessionService = lessonService; _lessionPartService = lessonPartService; _lessionExtendService = lessonExtendService; _loginLogService = loginLogService; _answerService = answerService; _fileProcess = fileProcess; _currentLang = StartUp.CurrentLang; _currentUser = StartUp.CurrentUser; }
public async Task <IActionResult> Edit(DefaultModel model, CPLangEntity 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 = !string.IsNullOrEmpty(model.ID) ? model.ID : item.ID; var _item = _service.GetByID(ID); item.ID = _item.ID; if (string.IsNullOrEmpty(item.Name)) { item.Name = _item.Name; } if (string.IsNullOrEmpty(item.Code)) { item.Code = _item.Code; } await _service.AddAsync(item); ViewBag.Data = _service.GetByID(ID); } ViewBag.Model = model; return(RedirectToAction("index")); }
public ViewPage(SysTemplateService templateService, SysTemplateDetailService templateDetailService , SysPageService pageService, SysTemplatePropertyService sysTemplateProperty) { _templateService = templateService; _templateDetailsService = templateDetailService; _currentLang = StartUp.CurrentLang; _pageService = pageService; _sysTemplateProperty = sysTemplateProperty; }
public CPApiController(ILogs logs, IConfiguration configuration) { _configuration = configuration; _logs = logs; _menu = new WebMenu(); _templateDetailsService = new SysTemplateDetailsService(); _templateService = new SysTemplateService(); _menuService = new CPMenuService(); _propertyService = new SysPropertyService(); currentLang = StartUp.CurrentLang; }
public async Task <IActionResult> Create(DefaultModel model, CPLangEntity item) { ViewBag.Title = "Thêm mới"; if (!string.IsNullOrEmpty(model.ID) || !string.IsNullOrEmpty(item.ID)) { return(RedirectToAction("Edit", new { model.ID })); } else { if (string.IsNullOrEmpty(item.Name) || string.IsNullOrEmpty(item.Code)) { } await _service.AddAsync(item); } return(View()); }
private static void GetCurrentResource(this HttpContext context, ref List <CPResourceEntity> currentResource, ref CPLangEntity currentLang) { string cookie = context.GetValue(Cookies.DefaultLang, false); if (string.IsNullOrEmpty(cookie)) { cookie = "vn"; } var lang = new CPLangService(); currentLang = lang.CreateQuery().SelectFirst(o => o.Activity == true && o.Code == cookie); // cache var cache = CacheExtends.GetDataFromCache <List <CPResourceEntity> >(cookie + "-" + CacheExtends.DefaultLang); // if (cache != null) { currentResource = cache; return; } var res = new CPResourceService(); currentResource = res.GetByLangID(currentLang.ID); }
private static void GetCurrentResource(this HttpContext context, IConfiguration configuration, ref List <CPResourceEntity> currentResource, ref CPLangEntity currentLang) { string cookie = context.GetValue(Cookies.DefaultLang, false); if (string.IsNullOrEmpty(cookie)) { cookie = "vn"; context.SetCurrentLang("VN"); } var lang = new CPLangService(configuration); currentLang = lang.CreateQuery().Find(o => o.IsActive == true && o.Code == cookie)?.SingleOrDefault(); if (currentLang != null) { // cache var cache = CacheExtends.GetDataFromCache <List <CPResourceEntity> >(cookie + "-" + CacheExtends.DefaultLang); // if (cache != null) { currentResource = cache; return; } var res = new CPResourceService(configuration); currentResource = res.GetByLangID(currentLang.ID); } }
public AdminController() { _menu = new WebMenu(); _currentLang = StartUp.CurrentLang; _currentUser = StartUp.CurrentUser; }