public ActionResult InformationRoleSystem(int id) { var db = new RoleBusiness(); var result = db.GetRoleSystemById(id); ViewBag.id = id; ViewBag.name = result.RoleName; return(View()); }
public ActionResult Themmoimenuchoquyen(int idrole) { int userid = user.Id; int roleid_login = user.Roleid; var db = new RoleBusiness(); var result = db.BS_Danhsachmenuthemmoivaoquyen(roleid_login, userid, idrole); return(PartialView(result)); }
public ActionResult _AddAccountUsingRole(int idAccount, int idRole) { var db = new RoleBusiness(); MenuPermission item = new MenuPermission(); item.RoleId = idRole; item.UserId = idAccount; var result = db.AddAccount_Menu_UsingRole(item); return(Json(new { result }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetAllAccountByRole(int IdRole) { ViewBag.id = IdRole; int userid = user.Id; int roleid = user.Roleid; int branchId = user.BranchId; var db = new RoleBusiness(); var result = db.ListUserByRoleId(roleid, userid, branchId, IdRole); return(PartialView(result)); }
public async Task DeleteAsync_LessThanOrEqualToZero_False(int id) { //Arrange _roleRepositoryMock.Setup(m => m.ExistsAsync(It.IsAny <int>())).Returns(() => Task.FromResult(false)); _roleRepositoryMock.Setup(m => m.DeleteAsync(It.IsAny <int>())).Returns(() => Task.FromResult(0)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act bool result = await roleBusiness.DeleteAsync(id); //Assert Assert.False(result); }
public async Task DeleteAsync_Exists_False() { //Arrange _roleRepositoryMock.Setup(m => m.ExistsAsync(It.IsAny <int>())).Returns(() => Task.FromResult(true)); _roleRepositoryMock.Setup(m => m.DeleteAsync(It.IsAny <int>())).Returns(() => Task.FromResult(0)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act bool result = await roleBusiness.DeleteAsync(Role.Id); //Assert Assert.True(result); }
public async Task ValidateRoleNameAsync_SameRolesNames_True() { //Arrange _roleRepositoryMock.Setup(m => m.GetByIdAsync(It.IsAny <int>())).Returns(() => Task.FromResult(Role)); _roleRepositoryMock.Setup(m => m.NameExistsAsync(It.IsAny <string>())).Returns(() => Task.FromResult(false)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act bool result = await roleBusiness.ValidateRoleNameAsync(Role); //Assert Assert.True(result); }
public async Task AddAsync_NameNotExists_True() { //Arrange _roleRepositoryMock.Setup(m => m.NameExistsAsync(It.IsAny <string>())).Returns(() => Task.FromResult(false)); _roleRepositoryMock.Setup(m => m.AddAsync(It.IsAny <Role>())).Returns(() => Task.FromResult(Role.Id)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act bool result = await roleBusiness.AddAsync(Role); //Assert Assert.True(result); }
public ActionResult _AddLevelRole(string RoleName, int IdLevelRole, string IsActive) { var db = new RoleBusiness(); Role item = new Role(); item.RoleName = RoleName; item.IsActive = bool.Parse(IsActive); item.Level = IdLevelRole; var result = db.AddRoleSystem(item); return(Json(new { result }, JsonRequestBehavior.AllowGet)); }
public async Task UpdateAsync_NotExists_False() { //Arrange _roleRepositoryMock.Setup(m => m.ExistsAsync(It.IsAny <int>())).Returns(() => Task.FromResult(false)); _roleRepositoryMock.Setup(m => m.UpdateAsync(It.IsAny <Role>())).Returns(() => Task.FromResult(0)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act bool result = await roleBusiness.UpdateAsync(Role); //Assert Assert.False(result); }
public ActionResult LoadListMenuByIdUserLogin(int idMember, int idrole) { ViewBag.id = idMember; int userid = user.Id; int roleid = user.Roleid; int branchId = user.BranchId; var db = new RoleBusiness(); var result = db.ListMenuByIdUserLogin(roleid, userid, branchId, idMember, idrole); return(PartialView(result)); }
//Khởi tạo danh sách chọn Module protected void InitSelectListItemRole(long?id) { var listItemModule = new List <SelectListItem>(); var listModule = new RoleBusiness().GetRolesByNotInRroup((long)id); foreach (var record in listModule) { listItemModule.Add(new SelectListItem { Text = record.Name, Value = record.Id.ToString() }); } ViewBag.ListItemModule = listItemModule; }
public async Task GetAllAsync_Null() { //Arrange List <Role> roles = null; _roleRepositoryMock.Setup(m => m.GetAllAsync()).Returns(() => Task.FromResult(roles)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act var result = await roleBusiness.GetAllAsync(); //Assert result.Should().BeNull(); }
public async Task GetByIdAsync_Null() { //Arrange Role role = null; _roleRepositoryMock.Setup(m => m.GetByIdAsync(It.IsAny <int>())).Returns(() => Task.FromResult(role)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act var result = await roleBusiness.GetByIdAsync(Role.Id); //Assert result.Should().BeNull(); }
public async Task <IHttpActionResult> Post([FromBody] RegisterViewModel registerView) { string lclRespondMsg = ValidationMessages.RespondMsg; try { var roleBusiness = new RoleBusiness(); var registerbusiness = new RegisterBusiness(); var role = registerView.Role; //CODESC:Check if user Exist if (registerbusiness.FindUser(registerView.userName, AuthenticationManager)) { ModelState.AddModelError("", "User name already taken"); return(Ok(ValidationMessages.UserNameTaken)); } //CODESC:Check if user does'nt Exist else create a role for him/her if (!roleBusiness.RoleExists(role)) { roleBusiness.CreateRole(role); } //CODESC:Than check if user exist var result = await registerbusiness.RegisterUser(new RegisterModel { UserName = registerView.userName, Password = registerView.Password }, AuthenticationManager); //CODESC:If The Result Passes Register Admin and Vendor if (result) { try { _dbVendor.Insert(registerView); _dbBusinessAdmin.Insert(registerView); registerbusiness.AddUserToRole(registerView.userName, role); lclRespondMsg = "Saved Successfully"; } catch (DbEntityValidationException e) { throw e.InnerException; } } } catch (Exception ex) { throw ex.InnerException; } return(Ok(lclRespondMsg)); }
private void FillRoleCmb() { _roleBLL = new RoleBusiness(_user); cmbRoleID.DataSource = null; cmbRoleID.DataSource = _roleBLL.GetAll(); cmbRoleID.DisplayMember = "Name"; cmbRoleID.ValueMember = "ID"; if (_selectedId > 0) { int roleInt = Convert.ToInt32(_emp.RoleID); Role empRole = _roleBLL.Get(roleInt); cmbRoleID.SelectedItem = empRole; } }
public async Task ValidateRoleNameAsync_NameExists_False() { //Arrange Role role = new Role { Id = 1, Name = "TestName2" }; _roleRepositoryMock.Setup(m => m.GetByIdAsync(It.IsAny <int>())).Returns(() => Task.FromResult(role)); _roleRepositoryMock.Setup(m => m.NameExistsAsync(It.IsAny <string>())).Returns(() => Task.FromResult(true)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act bool result = await roleBusiness.ValidateRoleNameAsync(Role); //Assert Assert.False(result); }
public ActionResult Roles(string key, int?page) { try { ViewData["key"] = key; int currentPageIndex = page.HasValue ? page.Value : 1; IList <Role> list = new RoleBusiness().GetByKey(key).ToPagedList(currentPageIndex, 20); return(View((IPagedList <Role>)list)); } catch (FaultException ex) { var exep = Function.GetExeption(ex); var codeExp = exep[1]; string url = "Error/ErrorFunction/" + codeExp; return(RedirectToActionPermanent(url)); } }
public ActionResult UpdateSelectInMenu(int id, string type, bool gt) { // kiểm tra quyền thêm sửa xóa của từng menu , nhớ truyền type tương ứng var sys = CheckActiveMenu.ReturnActive(SystemMessageConst.TypeAction.Update); if (sys.IsSuccess == false) { return(Json(new { result = sys }, JsonRequestBehavior.AllowGet)); } var db = new RoleBusiness(); EditSelectMenu item = new EditSelectMenu(); item.id = id; item.type = type; item.gt = gt; var result = db.Edit_Select_Menu(item); return(Json(new { result }, JsonRequestBehavior.AllowGet)); }
protected void Page_Load(object sender, EventArgs e) { pnlRed.Visible = false; pnlGreen.Visible = false; pnlYellow.Visible = false; pnlBlue.Visible = false; EB = new EmployeeBusiness(); RB = new RoleBusiness(); AB = new AccountBusiness(); DB = new DepartmentBusiness(); if (!IsPostBack) { loadData(); } GetRouteData(); String script = WebHelper.Instance.GetJqueryScript("App_Themes/js/jquery/custom_jquery.js"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "MessageWarning", script, true); }
// // GET: /CMSBHDType/Create public ActionResult EditRole(long id = 0) { try { InitSelectListItemStatus(); var roleBusiness = new RoleBusiness(); var record = roleBusiness.GetById(id); if (record == null) { return(HttpNotFound()); } return(View(record)); } catch (FaultException ex) { var exep = Function.GetExeption(ex); var codeExp = exep[1]; string url = "Error/ErrorFunction/" + codeExp; return(RedirectToActionPermanent(url)); } }
private void BindData(int nPageIndex) { string strWhere = string.Format(" AND R.COMPANYID={0} ", CompanyId); strWhere += string.Format(" AND R.PROJECTID={0} ", ddlProject.SelectedValue); int nCount = 0; //角色名 if (txtRoleName.Text.Trim().Length > 0) { strWhere += string.Format(" AND R.ROLENAME ='{0}' ", ValidatorHelper.SafeSql(txtRoleName.Text)); } DataTable dt = RoleBusiness.GetRoleList(nPageIndex, GlobalConsts.PageSize_Default, strWhere, out nCount); rptRoleInfo.DataSource = dt; rptRoleInfo.DataBind(); PageBar1.PageIndex = nPageIndex; PageBar1.PageSize = GlobalConsts.PageSize_Default; PageBar1.RecordCount = nCount; PageBar1.Draw(); }
public async Task GetByIdAsync_Role() { //Arrange _roleRepositoryMock.Setup(m => m.GetByIdAsync(It.IsAny <int>())).Returns(() => Task.FromResult(Role)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act var result = await roleBusiness.GetByIdAsync(Role.Id); //Assert result.Should().NotBeNull(); result.Id.Should().BeGreaterThan(0); result.Id.Should().Be(Role.Id); result.Name.Should().NotBeNullOrEmpty(); result.Name.Should().Be(Role.Name); result.Description.Should().NotBeNullOrEmpty(); result.Description.Should().Be(Role.Description); result.Active.Should().Be(Role.Active); result.CreatedAt.Should().HaveYear(DateTime.Now.Year); result.CreatedAt.Should().HaveMonth(DateTime.Now.Month); result.CreatedAt.Should().HaveDay(DateTime.Now.Day); result.CreatedAt.Should().HaveHour(DateTime.Now.Hour); result.CreatedAt.Should().HaveMinute(DateTime.Now.Minute); }
private void InitPage() { //账号状态 ControlHelper.ListContolDataBindFromEnum(rbtAccountStatus, typeof(ShareEnum.AccountStatus), "", "", ShareEnum.AccountStatus.Normal.ToString("d")); rbtAccountStatus.Items.Remove(rbtAccountStatus.Items.FindByValue(ShareEnum.AccountStatus.Del.ToString("d"))); //账号Id hidAccountId.Value = PageAccountId.ToString(); string strRoleIds = string.Empty; hidCompanyCode.Value = CompanyCode.ToString(); if (PageAccountId > 0)//修改页面 { USER_SHARE_ACCOUNTMODEL accountModel = AccountBusiness.GetAccountModel(PageAccountId); if (accountModel != null) { txtAccountName.Text = accountModel.ACCOUNTNAME; txtRealName.Text = accountModel.REALNAME; txtPwd.Attributes["value"] = accountModel.ORIGNALPWD; txtPwd2.Attributes["value"] = accountModel.ORIGNALPWD; txtLinkPhone.Text = CommonMethod.FinalString(accountModel.LINKPHONE); hidEmail.Value = CommonMethod.FinalString(accountModel.EMAIL); hidCompanyCode.Value = accountModel.COMPANYID.ToString(); ControlHelper.SelectFlg(rbtAccountStatus, accountModel.STATUS.ToString()); strRoleIds = CommonMethod.FinalString(accountModel.ROLEIDS); } else { Response.Write("不存在的账号信息!"); Response.End(); } } #region 角色 if (!IsInit) { DataTable dtProjects = CompanyBusiness.GetCompanyProjects(CompanyCode.ToString()); DataTable dtRoles = RoleBusiness.GetAccountRoleList(" AND R.COMPANYID=" + CompanyId); if (dtProjects != null && dtProjects.Rows.Count > 0 && dtRoles != null) { StringBuilder sbContent = new StringBuilder(""); foreach (DataRow dr in dtProjects.Rows) { sbContent.Append("<table class=\"table\" style=\"float:left; width:33%; margin-left:3px;\">"); sbContent.AppendFormat("<tr><td class='rhead' style=\"text-align:left;background-image: url('../../Resource/images/searchthead.gif');\" >{0}</td></tr>", dr["ProjectName"]); DataRow[] drRoles = dtRoles.Select("PROJECTID=" + dr["PROJECTID"], " ROLEID ASC "); foreach (DataRow drRole in drRoles) { sbContent.AppendFormat("<tr><td><input type='checkbox' name='role' id='{0}' value='{0}' {2} />{1}</td></tr>", drRole["ROLEID"], drRole["ROLENAME"], strRoleIds.IndexOf("," + drRole["ROLEID"] + ",") >= 0 ? "checked='checked'" : ""); } sbContent.Append("</table>"); } tdRoles.InnerHtml = sbContent.ToString(); } } else { trRoles.Visible = false; hidCompanyCode.Value = Enc.Decrypt(CommonMethod.FinalString(Request.QueryString["code"]), UrlEncKey); } #endregion }
protected override void OnInit(EventArgs e) { m_Role = new RoleBusiness(); base.OnInit(e); }
protected override void OnUnload(EventArgs e) { m_Role.Dispose(); m_Role = null; base.OnUnload(e); }
public RoleBusinessTest(TemplateFixture fixture) { _roleBusiness = fixture.ServiceProvider.GetService <RoleBusiness>(); }
public RoleController(ILogger <RoleController> logger, RoleBusiness roleBusiness, IMapper mapper) { _logger = logger; _roleBusiness = roleBusiness; _mapper = mapper; }
public RoleController(RoleBusiness roleBusiness) { _roleBusiness = roleBusiness; }
public RoleController(RepositoryContext context, IConfiguration conf) { buzz = new RoleBusiness(context, conf); }