예제 #1
0
        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();
                    }
                }
            }
        }
예제 #2
0
        // 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));
        }
예제 #3
0
        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));
        }
예제 #4
0
 public ActionResult <RoleModel> GetById(int id)
 {
     try
     {
         RoleModel record = _role.GetById(id);
         return(Ok(record));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
        public IHttpActionResult Get(string id)
        {
            var result = _roleServices.GetById(id);

            return(ApiHelper.ReturnHttpAction(result, this));
        }