private List <Role> GetRoleList() { RoleDAL dal = new RoleDAL(); var result = dal.SearchRole(txtRoleName.Text); return(result); }
public IQueryable <Role> GetAll() { RoleDAL dalObject = new RoleDAL(); IQueryable <Role> results = dalObject.GetAll(); return(results); }
public static bool ProcessControls(List <RoleControl> _editingRoleControls) { bool success = true; foreach (RoleControl control in _editingRoleControls) { if (control.status == "NEW") { if (!RoleDAL.AddControlToRole(control, control.RoleID)) { success = false; } ; } else if (control.status == "UPDATE") { if (!RoleDAL.UpdateControl(control, control.RoleID)) { success = false; } ; } } return(success); }
public Role getUserRole(String uid) { if (SafeUser != null && SafeUser.isLoggedIn()) { try { SqlHelper helper = new SqlHelper(); SecurityDAL sdal = new SecurityDAL(helper); if (sdal.hasPermission(SafeUser.SignIN.UID, "USER")) { RoleDAL dal = new RoleDAL(helper); log(200, "A role is successfully got"); return(dal.getUserRole(uid)); } else { log(600, "Permission denied"); } }catch (Exception ex) { log(ex); } } return(null); }
public string GetRoleString(Borrower b) { string rv = ""; RoleDAL dal = new RoleDAL(_connection); { // since we are doing a lot of custom string work // use a string builder to increase performance StringBuilder sb = new StringBuilder(); Role r = dal.RoleFindByID(b.RoleID); // the string builder is passed to the helper function // which will append the role info to the string builder // no need to lowercase the operation, // since it is hardcoded to lowercase AddRole(sb, "list", r.ListOperation); AddRole(sb, "view", r.ViewOperation); // details added as synonym for view AddRole(sb, "details", r.ViewOperation); AddRole(sb, "create", r.CreateOperation); AddRole(sb, "update", r.UpdateOperation); // edit added as synonym for update AddRole(sb, "edit", r.UpdateOperation); AddRole(sb, "delete", r.DeleteOperation); // the string builder is then converted to the final string rv = sb.ToString(); } return(rv); }
/// <summary> /// 修改 /// </summary> /// <param name="roleVM"></param> public static void Edit(RoleVM roleVM) { Mapper.CreateMap <RoleVM, Role>(); Role role = Mapper.Map <RoleVM, Role>(roleVM); RoleDAL.Update(role); }
public int RoleUpdateSafe( int RoleID, string oldRoleName, string oldCreateOperation, string oldUpdateOperation, string oldDeleteOperation, string oldListOperation, string oldViewOperation, string newRoleName, string newCreateOperation, string newUpdateOperation, string newDeleteOperation, string newListOperation, string newViewOperation) { RoleDAL dal = new RoleDAL(_connection); return(dal.RoleUpdateSafe(RoleID, oldRoleName, oldCreateOperation, oldUpdateOperation, oldDeleteOperation, oldListOperation, oldViewOperation, newRoleName, newCreateOperation, newUpdateOperation, newDeleteOperation, newListOperation, newViewOperation )); }
static public string QueryAll(out string msg, ref int totalPage, ref int currentPage) { List <Role> list = RoleDAL.QueryAll(out msg); if (list == null) { totalPage = 0; currentPage = -1; return(null); } totalPage = (int)System.Math.Floor((decimal)(list.Count / 10)); if (list.Count != 0 && list.Count % 10 == 0) { --totalPage; } if (currentPage < totalPage) { ++currentPage; } try { return(JsonConvert.SerializeObject(list.GetRange(currentPage * 10, 10))); } catch { return(JsonConvert.SerializeObject(list.GetRange(currentPage * 10, list.Count - currentPage * 10))); } }
protected void rpRoleList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Add") { if (e.Item.ItemType == ListItemType.Header) { TextBox txtRoleNameAdd = e.Item.FindControl("txtRoleNameAdd") as TextBox; Role role = new Role() { Role_Name = txtRoleNameAdd.Text, IsActive = true }; RoleDAL dal = new RoleDAL(); dal.AddRole(role); dal.Save(); } } else if (e.CommandName == "Delete") { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { HiddenField hfId = e.Item.FindControl("hfId") as HiddenField; RoleDAL dal = new RoleDAL(); dal.DeleteRole(int.Parse(hfId.Value)); } } Utility.BindDataToRepeater(rpRoleList, GetRoleList()); SetFocus(source); Response.Redirect("AccessControlManagement.aspx?tabno=2"); }
public async Task <ActionResult> DeleteRole(string id) { RoleDAL dal = new RoleDAL(); await dal.Delete(id); return(ToJsonResult("Success")); }
public async Task <ActionResult> EditRole(RoleViewModel model) { RoleDAL dal = new RoleDAL(); await dal.Update(model.CastDB(model)); return(ToJsonResult("Success")); }
static public List <Role> GetAllBind() { DataTable dt = RoleDAL.GetAll(); List <Role> RoleList = GenericConvertDataTableToList.ConvertDataTable <Role>(dt); return(RoleList); }
public IQueryable <Role> FindBy(System.Linq.Expressions.Expression <Func <Role, bool> > predicate) { RoleDAL dalObject = new RoleDAL(); IQueryable <Role> results = dalObject.FindBy(predicate); return(results); }
public BaseItemRes <InitDataInfo> Test() { var userDAL = new UserDAL(); var lstUser = userDAL.AsQueryable().ToList(); var roleDAL = new RoleDAL(); var lstRole = roleDAL.AsQueryable().ToList(); var authorityDAL = new AuthorityDAL(); var lstAuthority = authorityDAL.AsQueryable().ToList(); var roleAuthorityDAL = new RoleAuthorityDAL(); var lstRoleAuthority = roleAuthorityDAL.AsQueryable().ToList(); var userRoleDAL = new UserRoleDAL(); var lstUserRole = userRoleDAL.AsQueryable().ToList(); var initData = new InitDataInfo() { Users = lstUser, Roles = lstRole, Authoritys = lstAuthority, RoleAuthoritys = lstRoleAuthority, UserRoles = lstUserRole }; return(BaseItemRes <InitDataInfo> .Ok(initData)); }
public RoleDAL ToDAL() { //Makest it easy to pass values back to the data access layer RoleDAL ReturnValue = new RoleDAL(); ReturnValue.RoleID = RoleID; ReturnValue.RoleName = RoleName; return(ReturnValue); }
public List <Role> CollectRoles(Role iRole) { List <Role> listRoles = new List <Role>(); RoleDAL iRoleDAL = new RoleDAL(); listRoles = iRoleDAL.SelectRolesFromTable(iRole); return(listRoles); }
public AdminBLL() { rd = new RoleDAL(); pd = new PermissionsDAL(); ad = new AdminDAL(); dd = new DealerBLL(); sd = new StoreBLL(); }
public static Role GetVRoleByString(Role str) { //查询角色表的时候更新禁言 封号状态 RoleDAL.UpdateFreezeNoSpeak(Convert.ToInt32(str.ID)); return(RoleDAL.GetVRoleByID(str)); }
// GET: Role public async Task <ActionResult> Index() { RoleDAL dal = new RoleDAL(); var rolelist = await dal.GetAll(); var viewlist = rolelist.Select(t => new RoleViewModel().CastView(t)); return(View(viewlist)); }
/// <summary> /// 根据ID查询 /// </summary> /// <param name="id"></param> /// <returns></returns> public static RoleVM GetByID(int id) { Role role = RoleDAL.Find(id); Mapper.CreateMap <Role, RoleVM>(); RoleVM roleVM = Mapper.Map <Role, RoleVM>(role); return(roleVM); }
public async Task <ActionResult> EditRole(string id) { RoleDAL dal = new RoleDAL(); var db = await dal.GetRole(id); var model = new RoleViewModel().CastView(db); return(View(model)); }
/// <summary> /// 新增 /// </summary> /// <param name="roleVM"></param> public static void Create(RoleVM roleVM) { Mapper.CreateMap <RoleVM, Role>(); Role role = Mapper.Map <RoleVM, Role>(roleVM); role.CreateTime = DateTime.Now; role.IsDeleted = false; RoleDAL.Add(role); }
public void RoleTest() { // arrange RoleDAL dal = new RoleDAL(MagicSetup.Connection); // act create int rv1 = dal.RoleCreate("Test1", "1", "2", "3", "4", "5"); Assert.IsTrue(rv1 > 0, $"RoleCreate failed rv = {rv1}"); Role a = dal.RoleFindByID(rv1); Assert.IsNotNull(a, $"RoleFindByID for ID {rv1} (just created) returned null"); Assert.IsTrue(a.RoleName == "Test1", $"RoleName was expected to be 'Test1' but found {a.RoleName}"); Assert.IsTrue(a.CreateOperation == "1", $"CreateOperation was expected to be 1 but was actually {a.CreateOperation}"); Assert.IsTrue(a.UpdateOperation == "2", $"UpdateOperation was expected to be 2 but was actually {a.UpdateOperation}"); Assert.IsTrue(a.DeleteOperation == "3", $"DeleteOperation was expected to be 3 but was actually {a.DeleteOperation}"); Assert.IsTrue(a.ListOperation == "4", $"ListOperation was expected to be 4 but was actually {a.ListOperation}"); Assert.IsTrue(a.ViewOperation == "5", $"ViewOperation was expected to be 5 but was actually {a.ViewOperation}"); int countofRoles = dal.RolesObtainCount(); Assert.IsTrue(countofRoles > 0, $"RolesObtainCount should be greater than 0 it is {countofRoles}"); List <Role> Roles = dal.RolesGetAll(); Assert.IsTrue(Roles.Count == countofRoles, $"RolesGetAll should have brought back {countofRoles} records, but it only found {Roles.Count}"); DateTime now = DateTime.Now; int number = dal.RoleUpdateJust(rv1, "Test1New", "10", "20", "30", "40", "50"); Assert.IsTrue(number == 1, $"RoleUpdateJust was expected to return 1, but actually returned {number}"); a = dal.RoleFindByID(rv1); Assert.IsNotNull(a, $"RoleFindByID for ID {rv1} (just updated) returned null"); Assert.IsTrue(a.RoleName == "Test1New", $"RoleName after update was expected to be 'Test1New' but was actually '{a.RoleName}'"); Assert.IsTrue(a.CreateOperation == "10", $"CreateOperation was expected to be 10 but was actually {a.CreateOperation}"); Assert.IsTrue(a.UpdateOperation == "20", $"UpdateOperation was expected to be 20 but was actually {a.UpdateOperation}"); Assert.IsTrue(a.DeleteOperation == "30", $"DeleteOperation was expected to be 30 but was actually {a.DeleteOperation}"); Assert.IsTrue(a.ListOperation == "40", $"ListOperation was expected to be 40 but was actually {a.ListOperation}"); Assert.IsTrue(a.ViewOperation == "50", $"ViewOperation was expected to be 50 but was actually {a.ViewOperation}"); number = dal.RoleUpdateSafe(rv1, "Test1New", "10", "20", "30", "40", "50", "1", "100", "200", "300", "400", "500"); Assert.IsTrue(number == 1, $"RoleUpdateSafe was expected to return 1 but actually returned {number}"); a = dal.RoleFindByID(rv1); Assert.IsNotNull(a, $"RoleFindByID for ID {rv1} (just safe updated) returned null"); Assert.IsTrue(a.RoleName == "1", $"Rolename after safeupdate was expected to be '1', but was '{a.RoleName}"); Assert.IsTrue(a.CreateOperation == "100", $"CreateOperation was expected to be 100 but was actually {a.CreateOperation}"); Assert.IsTrue(a.UpdateOperation == "200", $"UpdateOperation was expected to be 200 but was actually {a.UpdateOperation}"); Assert.IsTrue(a.DeleteOperation == "300", $"DeleteOperation was expected to be 300 but was actually {a.DeleteOperation}"); Assert.IsTrue(a.ListOperation == "400", $"ListOperation was expected to be 400 but was actually {a.ListOperation}"); Assert.IsTrue(a.ViewOperation == "500", $"ViewOperation was expected to be 500 but was actually {a.ViewOperation}"); number = dal.RoleUpdateSafe(rv1, "Test1New", "10", "20", "30", "40", "50", "1", "100", "200", "300", "400", "500"); Assert.IsTrue(number == 0, $"Roleupdatesafe was expected to return 0, but it actually returned {number}"); dal.RoleDelete(rv1); }
public RoleBLL FindRoleByRoleID(int RoleID) { RoleBLL proposedReturnValue = null; RoleDAL DataLayerObject = _context.FindRoleByRoleID(RoleID); if (null != DataLayerObject) { proposedReturnValue = new RoleBLL(DataLayerObject); } return proposedReturnValue; }
static public string Query(string name, out string msg) { List <Role> list = RoleDAL.Query(name, out msg); if (list == null) { return(null); } return(JsonConvert.SerializeObject(list)); }
public async Task <ActionResult> EditPermission(string id, string perid) { RoleDAL rd = new RoleDAL(); var result = await rd.FlushPermission(id, perid.Trim(',').Split(',')); if (result) { return(ToJsonResult("Success")); } return(ToJsonResult("Failed")); }
public RoleBLL RoleFindByID(int RoleID) { RoleBLL proposedReturnValue = null; RoleDAL item = _context.RoleFindByID(RoleID); if (item != null) { proposedReturnValue = new RoleBLL(item); } return(proposedReturnValue); }
public void CreateTest() { RoleDAL dal = new RoleDAL(ConfigurationManager.ConnectionStrings["IMDB"].ConnectionString); var result = dal.CreateRole(new RoleDTO { RoleName = "Адмін", Description = "Може взаэмодіяти з юзерами", }); Assert.IsTrue(result.RoleId != 0, "returned ID should be more than zero"); }
public RoleBLL RoleFindByID(int RoleID) { RoleBLL ExpectedReturnValue = null; RoleDAL info = context.RoleFindByID(RoleID); if (info != null) { ExpectedReturnValue = new RoleBLL(info); } return(ExpectedReturnValue); }
public virtual void Update(RoleDataModel role) { if (role.ID > 0) { RoleDAL.Update(role); } else { throw new Exception("Page not found"); } }
// To pass 'Role' data in RoleDAL Data Access Layer to show Active type records public DataTable LoadAllRole(int LoggedInUser, string returnmsg) { RoleDAL rDAL = new RoleDAL(); try { return rDAL.LoadAllRole(LoggedInUser, returnmsg); } catch { throw; } finally { rDAL = null; } }
// To pass 'Role' data in RoleDAL Data Access Layer to show Active and Inactive type records public DataTable LoadActiveRole(bool IsActive, int LoggedInUser, string Ret) { RoleDAL rDAL = new RoleDAL(); try { return rDAL.LoadActiveRole(IsActive, LoggedInUser, Ret); } catch { throw; } finally { rDAL = null; } }
// To pass 'Role' data in RoleDAL Data Access Layer for insertion public int InsertRole(string RoleName, string RoleDescription, bool IsActive, int LoginUser, string Ret) { RoleDAL rDAL = new RoleDAL(); try { return rDAL.InsertRole(RoleName, RoleDescription, IsActive, LoginUser, Ret); } catch { throw; } finally { rDAL = null; } }
// To pass 'Role' data in RoleDAL Data Access Layer to show Change Status of selected RoleId record public int ChangeRoleStatus(int RoleId, int LoggedInUser, string Ret, bool IsActive) { RoleDAL rDAL = new RoleDAL(); try { return rDAL.ChangeRoleStatus(RoleId, LoggedInUser, Ret, IsActive); } catch { throw; } finally { rDAL = null; } }
// To pass 'Role' data in RoleDAL Data Access Layer to show selected RoleId record public DataTable SelectRoleID(int RoleId, int LoggedInUser, string Ret) { RoleDAL rDAL = new RoleDAL(); try { return rDAL.SelectRoleID(RoleId, LoggedInUser, Ret); } catch { throw; } finally { rDAL = null; } }
public RoleBLL() { dal = new RoleDAL(); }