コード例 #1
0
        public ActionResult Index(Int16 RId = 0)
        {
            RoleUserAccessMapViewModel objEntity = new RoleUserAccessMapViewModel();

            RoleRepository objRoleRepository = new RoleRepository();

            objEntity.RId = RId;
            var objRoleEntity = objRoleRepository.Select(RoleFlags.SelectAllExcludeAdmin.GetHashCode(), new RoleViewModel() { });
            objEntity.RoleViewModelList = new SelectList(objRoleEntity, "RoleId", "RoleName");

            //
            RoleUserAccessMapRepository objRoleUserAccessMapRepository = new RoleUserAccessMapRepository();
            objEntity.RoleUserAccessMapList = new List<RoleUserAccessMapViewModel>();
            objEntity.RoleUserAccessMapList = objRoleUserAccessMapRepository.Select((RId == 0) ? RoleUserAccessMapFlags.SelectAll.GetHashCode() : RoleUserAccessMapFlags.SelectByRoleId.GetHashCode(), new RoleUserAccessMapViewModel()
            {

                RoleId = RId
            });
            if (objEntity.RoleUserAccessMapList.Count == 0)
            {

                this.Flash("Error", "No Role UserAccess");
            }

            return View(objEntity);
        }
コード例 #2
0
        //public RoleUserAccessMapViewModel Edit(int Flag, RoleUserAccessMapViewModel objEntity)
        //{
        //    try
        //    {
        //        Database objDB = base.GetDatabase();
        //        // Create a suitable command type and add the required parameter.
        //        using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SPS_RoleUserAccessMapVIEWMODELUPDATE))
        //        {
        //            objDB.AddInParameter(sprocCmd, COLUMN_NAME_FLAG, DbType.Int32, Flag);
        //            objDB.AddInParameter(sprocCmd, COLUMN_NAME_RoleUserAccessMap_ID, DbType.Int32, objEntity.RoleUserAccessMapId);
        //            objDB.AddInParameter(sprocCmd, COLUMN_NAME_RoleUserAccessMap_NAME, DbType.String, objEntity.RoleUserAccessMapName);
        //            objDB.AddInParameter(sprocCmd, COLUMN_NAME_SHORT_NAME, DbType.String, objEntity.ShortName);
        //            objDB.AddInParameter(sprocCmd, COLUMN_NAME_RoleUserAccessMap_STATUS, DbType.Int32, objEntity.RoleUserAccessMapStatus);
        //            objDB.AddInParameter(sprocCmd, COLUMN_NAME_SORT_ORDER, DbType.Int16, objEntity.SortOrder);
        //            objDB.AddInParameter(sprocCmd, COLUMN_NAME_MODIFIED_DATE, DbType.DateTime, objEntity.ModifiedDate);
        //            objDB.AddInParameter(sprocCmd, COLUMN_NAME_MODIFIED_BY, DbType.Int32, objEntity.ModifiedBy);
        //            objDB.AddOutParameter(sprocCmd, COLUMN_NAME_RESULT, DbType.Int32, objEntity.Result);
        //            objDB.ExecuteNonQuery(sprocCmd);
        //            objEntity.Result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, COLUMN_NAME_RESULT));
        //        }
        //        //
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //    finally
        //    {
        //    }
        //    return objEntity;
        //}
        public RoleUserAccessMapViewModel Insert(RoleUserAccessMapViewModel objEntity)
        {
            try
            {
                Database objDB = base.GetDatabase();
                // Create a suitable command type and add the required parameter.
                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SPS_ROLEUSERACCESSMAPVIEWMODELINSERT))
                {

                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_ROLE_ID, DbType.Int32, objEntity.RoleId);
                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_SELECTEDROLEUSERACCESSMAPXML, DbType.Xml, objEntity.SelectedRoleUserAccessMap);

                    objDB.AddOutParameter(sprocCmd, COLUMN_NAME_RESULT, DbType.Int32, objEntity.Result);
                    objDB.ExecuteNonQuery(sprocCmd);

                    objEntity.Result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, COLUMN_NAME_RESULT));
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return objEntity;
        }
コード例 #3
0
        public ActionResult Index(RoleUserAccessMapViewModel objEntity)
        {
            RoleRepository objRoleRepository = new RoleRepository();
            RoleUserAccessMapRepository objRoleUserAccessMapRepository = new RoleUserAccessMapRepository();
            if (objEntity.RId <= 0)
            {
                ModelState.AddModelError("RId", "Select a role");
            }
            objEntity.RoleId = objEntity.RId;

            if (ModelState.IsValid)
            {

                objEntity.SelectedRoleUserAccessMap = BuildCreateXmlInputStringRoleUserAccessMap(objEntity.RoleUserAccessMapList);
                objRoleUserAccessMapRepository.Insert(objEntity);
                //selected location
                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    this.Flash("Success", "Role User Access updated successfully");

                    //reload all new setting
                    MenuHelpers.SetMenuByRoleMaster();
                    MenuHelpers.SetMenuByRoleMain();

                    return RedirectToAction("Index", new { RId = objEntity.RId });
                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {

                    this.Flash("Error", "Role User Access failed to update");
                }

            }

            var objRoleEntity = objRoleRepository.Select(RoleFlags.SelectAllExcludeAdmin.GetHashCode(), new RoleViewModel() { });
            objEntity.RoleViewModelList = new SelectList(objRoleEntity, "RoleId", "RoleName");

            //

            objEntity.RoleUserAccessMapList = new List<RoleUserAccessMapViewModel>();
            objEntity.RoleUserAccessMapList = objRoleUserAccessMapRepository.Select((objEntity.RoleId == 0) ? RoleUserAccessMapFlags.SelectAll.GetHashCode() : RoleUserAccessMapFlags.SelectByRoleId.GetHashCode(), new RoleUserAccessMapViewModel()
            {

                RoleId = objEntity.RoleId
            });
            if (objEntity.RoleUserAccessMapList.Count == 0)
            {

                this.Flash("Error", "No Role UserAccess");
            }

            return View(objEntity);
        }
コード例 #4
0
        public List<RoleUserAccessMapViewModel> Select(int Flag, RoleUserAccessMapViewModel objEntity)
        {
            var objEntityList = new List<RoleUserAccessMapViewModel>();
            try
            {
                Database objDB = base.GetDatabase();
                // Create a suitable command type and add the required parameter.
                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SPS_ROLEUSERACCESSMAPVIEWMODELSELECT))
                {
                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_FLAG, DbType.Int32, Flag);
                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_USERACCESS_ID, DbType.Int16, objEntity.UserAccessId);
                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_ROLE_ID, DbType.Int16, objEntity.RoleId);

                    using (IDataReader reader = objDB.ExecuteReader(sprocCmd))
                    {
                        while (reader.Read())
                        {
                            var objEntityViewModel = new RoleUserAccessMapViewModel();

                            objEntityViewModel.UserAccessId = reader.GetColumnValue<Int16>(COLUMN_NAME_USERACCESS_ID);
                            //objEntityViewModel.RoleId = reader.GetColumnValue<Int16>(COLUMN_NAME_ROLE_ID);

                            objEntityViewModel.UserAccessTitle = reader.GetColumnValue<string>(COLUMN_NAME_USERACCESS_TITLE);
                            objEntityViewModel.AddPermission = reader.GetColumnValue<Boolean>(COLUMN_NAME_ADDPERMISSION);
                            objEntityViewModel.EditPermission = reader.GetColumnValue<Boolean>(COLUMN_NAME_EDITPERMISSION);
                            objEntityViewModel.ViewPermission = reader.GetColumnValue<Boolean>(COLUMN_NAME_VIEWPERMISSION);

                            objEntityViewModel.DeletePermission = reader.GetColumnValue<Boolean>(COLUMN_NAME_DELETEPERMISSION);

                            if (objEntityViewModel != null)
                            {
                                objEntityList.Add(objEntityViewModel);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return objEntityList;
        }