public ActionResult AdminPagesMoveDown(int postId) { AdminPages adminPages = new AdminPages(); switch (adminPages.MoveDown(postId)) { case 0: BackEndSessions.CurrentMenu = adminPages.GetMenuByGroupId(BackEndSessions.CurrentUser.GroupId); ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.PageSuccessfullyMoved); break; case 2: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist); break; case 3: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.PageCannotBeMoved); break; default: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError); break; } return(RedirectToAction("AdminPages")); }
public ActionResult Login(BackEndLogin backEndLogin, string ReturnUrl) { AdminPage backEndPage = new AdminPage(); backEndPage.PageName = "Login"; ViewBag.AdminPage = backEndPage; if (ModelState.IsValidOrRefresh()) { Users users = new Users(); User user = users.GetUserByUserNameAndPassword(backEndLogin.Username, backEndLogin.Password); if (user.IsNotNull()) { ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.SuccessfullyLoggedIn); var tenant = users.GetTenantByUsername(backEndLogin.Username); if (tenant != null) { // 1. Tạo người dùng (User) - UserName, Password // 2. Quản lý công ty -> Tạo công ty (Tenant) - Tên, MST, ServerName, DbBName, DbUserName, DbPassword, UserName // 3. Quản lý công ty -> Cập nhật lại thông tin UserName cho công ty (Tenant) nếu Tenant chưa có UserName // // Mỗi 1 công ty (Tenant) có duy nhất 1 mã số thuế (trùng với tên đăng nhập vào hệ thống) // Mỗi 1 công ty (Tenant) có duy nhất 1 connection string = { ServerName, DbBName, DbUserName, DbPassword, DbPort (optional) } // Mỗi 1 công ty (Tenant) có nhiều Đơn Vị Cơ Sở (dvcs) // Khi Login xong thì connection string sẽ thay đổi theo mã số thuế { ServerName, DbBName, DbUserName, DbPassword, DbPort (optional) } AdoHelper2.ConnectionString = DataHelper.BuildDynamicConnectionString(ConfigurationManager.ConnectionStrings["SM17ConnectionString"].ConnectionString, tenant); user.Dvcs = tenant.Dvcs; user.Tenant = tenant; } BackEndSessions.CurrentUser = user; AdminPages backEndPages = new AdminPages(); BackEndSessions.CurrentMenu = backEndPages.GetMenuByGroupId(user.GroupId); if (ReturnUrl.IsNotEmptyOrWhiteSpace()) { return(Redirect(HttpUtility.UrlDecode(ReturnUrl))); } else { return(RedirectToAction("Dashboard")); } } else { ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UsernameOrPasswordNotValid); } } return(View(backEndLogin)); }
public ActionResult AdminPagesEdit(BackEndAdminPagesEdit backEndAdminPagesEdit, int id) { if (ModelState.IsValidOrRefresh()) { string groupsPermissions = string.Empty; foreach (GroupPermission g in backEndAdminPagesEdit.GroupsPermissions) { foreach (Permission p in g.Permissions) { if (p.PermissionValue) { groupsPermissions += g.GroupId + "," + p.PermissionCode.ToString().ToLower() + "|"; } } } AdminPages adminPages = new AdminPages(); int? result = adminPages.Edit(id, backEndAdminPagesEdit.PageParentId, backEndAdminPagesEdit.PageName, backEndAdminPagesEdit.Target, backEndAdminPagesEdit.Url, backEndAdminPagesEdit.ShowInMenu, backEndAdminPagesEdit.IsActive, backEndAdminPagesEdit.CssClass, groupsPermissions); switch (result) { case 0: BackEndSessions.CurrentMenu = adminPages.GetMenuByGroupId(BackEndSessions.CurrentUser.GroupId); ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyEdited); break; case 2: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist); ViewData.IsFormVisible(false); break; case 3: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.PageAlreadyExists); break; default: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError); break; } } return(View(backEndAdminPagesEdit)); }
public ActionResult Impersonate(BackEndImpersonate backEndImpersonate) { if (ModelState.IsValidOrRefresh()) { BackEndSessions.CurrentUser = new Users().GetUserByUserName(backEndImpersonate.Username); AdminPages backEndPages = new AdminPages(); BackEndSessions.CurrentMenu = backEndPages.GetMenuByGroupId(BackEndSessions.CurrentUser.GroupId); //Remove other specific sessions List <string> sessionsToRemove = Session.Keys.Cast <string>().Where(key => key.StartsWith("Data_") || key.StartsWith("Querystring_")).ToList(); foreach (string key in sessionsToRemove) { Session.Remove(key); } } return(PartialView(backEndImpersonate)); }
public ActionResult Login(BackEndLogin backEndLogin, string ReturnUrl) { AdminPage backEndPage = new AdminPage(); backEndPage.PageName = "Login"; ViewBag.AdminPage = backEndPage; if (ModelState.IsValidOrRefresh()) { Users users = new Users(); User user = users.GetUserByUserNameAndPassword(backEndLogin.Username, backEndLogin.Password); if (user.IsNotNull()) { ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.SuccessfullyLoggedIn); BackEndSessions.CurrentUser = user; AdminPages backEndPages = new AdminPages(); BackEndSessions.CurrentMenu = backEndPages.GetMenuByGroupId(user.GroupId); if (ReturnUrl.IsNotEmptyOrWhiteSpace()) { return(Redirect(HttpUtility.UrlDecode(ReturnUrl))); } else { return(RedirectToAction("Index")); } } else { ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UsernameOrPasswordNotValid); } } return(View(backEndLogin)); }