private void _view_OnUpdateData(object sender, EventArgs e) { using (new WaitCursorHandler()) { ListDataGrid listDataGrid = null; if (sender is ListDataGrid) { listDataGrid = (ListDataGrid)sender; } else { listDataGrid = _view.ListDataGrid; } if (listDataGrid != null && listDataGrid.SelectedItem != null) { var model = _services.GetById(((RoleModel)listDataGrid.SelectedItem).id); if (model != null) { var view = new RoleEntryView(false, model); view.OnSaveData += RoleEntryView_OnSaveData; view.ShowDialog(); } } } }
// GET: Roles/Create public ActionResult SetRoleMenus(int id) { var role = _roleServices.GetById(id); // var menus = _menuServices.GetMenusByCategoryId(SettingsManager.Menu.BackMenuCId); // int[] menuIds = role.RoleMenus?.Select(m => m.MenuId).ToArray(); SetRoleMenusVM vm = new SetRoleMenusVM { RoleId = id, // Menus = menus, // MenuIds = menuIds }; return(PartialView("_SetRoleMenus", vm)); }
public IActionResult Authenticate([FromBody] AuthRequest authRequest) { if (!ModelState.IsValid) { return(BadRequest("Invalid Email")); } Employee emp = _employeeServices.GetEmployeeByEmail(authRequest.Email); if (emp == null) { return(BadRequest()); } var userRole = _userRoleServices.GetUserRoleByUserId(emp.Id); if (userRole == null) { return(BadRequest()); } var role = _roleServices.GetById(userRole.RoleId); if (role == null) { return(BadRequest()); } emp.Role = role.Name; string token = _token.Create(emp.Name, role.Name); AuthResponse response = new AuthResponse() { Token = token, Employee = emp }; return(Ok(response)); }
public ActionResult <RoleModel> GetById(int id) { try { RoleModel record = _role.GetById(id); return(Ok(record)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public void ShouldReturnModelMatchingId() { RoleModel model = null; var idToGet = 1; try { model = (RoleModel)_services.GetById(idToGet); } catch (DataAccessException ex) { _testOutputHelper.WriteLine(ex.DataAccessStatusInfo.GetFormatedValues()); } Assert.True(model != null); Assert.True(model.id == idToGet); if (model != null) { TestsHelper.WriteModel(_testOutputHelper, model); } }
public IHttpActionResult Get(string id) { var result = _roleServices.GetById(id); return(ApiHelper.ReturnHttpAction(result, this)); }