Exemplo n.º 1
0
        public IEnumerable <SYS_FunctionPermissionsDto> GetFunctionPermissionsByGroupCode(string groupCode)
        {
            List <SYS_FunctionPermissionsDto> listOfFunctionPermissions = new List <SYS_FunctionPermissionsDto>();
            List <sy_operas> listOfRight = this.GetListOfRights();

            //1. Get all functions for group
            using (BaseDao context = new BaseDao())
            {
                IQueryable <sy_functions> functions = context.sy_functions.AsQueryable();
                foreach (sy_functions item in functions)
                {
                    SYS_FunctionPermissionsDto newFunction = new SYS_FunctionPermissionsDto()
                    {
                        FunctionPermissionID = Guid.NewGuid(),
                        GroupCode            = groupCode,
                        FunctionID           = item.ID,
                        FunctionCode         = item.FunctionID,
                        FunctionNameVN       = item.Name1,
                        FunctionNameEL       = item.Name2,
                        FunctionNameJP       = item.Name3,
                    };
                    listOfFunctionPermissions.Add(newFunction);
                }
            }
            //--------------------------------------------------------------------------------
            //2. Assign Function's permission
            IQueryable <ms_permissionsassign> listofFunctionAssign = this.GetExsitingFunctionPermission(groupCode);

            foreach (ms_permissionsassign ms_permissionsassign in listofFunctionAssign)
            {
                sy_functionmapping sy_functionmapping = this.GetFunctionMapping(ms_permissionsassign.MappingID);
                if (sy_functionmapping != null)
                {
                    SYS_FunctionPermissionsDto sys_FunctionPermission = listOfFunctionPermissions.Where(c => c.FunctionCode == sy_functionmapping.FunctionID).FirstOrDefault();
                    if (sys_FunctionPermission != null)
                    {
                        sys_FunctionPermission.MappingID = ms_permissionsassign.MappingID;
                        sy_operas operate = listOfRight.Where(c => c.OperID == sy_functionmapping.OperID).FirstOrDefault();
                        if (operate != null)
                        {
                            sys_FunctionPermission.Add    = (operate.Name2 == "Add");
                            sys_FunctionPermission.All    = (operate.Name2 == "All");
                            sys_FunctionPermission.Close  = (operate.Name2 == "Close");
                            sys_FunctionPermission.Delete = (operate.Name2 == "Delete");
                            sys_FunctionPermission.Edit   = (operate.Name2 == "Edit");
                            sys_FunctionPermission.Export = (operate.Name2 == "Export");
                            sys_FunctionPermission.Import = (operate.Name2 == "Import");
                            sys_FunctionPermission.Lock   = (operate.Name2 == "Lock");
                            sys_FunctionPermission.Open   = (operate.Name2 == "Open");
                            sys_FunctionPermission.Print  = (operate.Name2 == "Print");
                            sys_FunctionPermission.View   = (operate.Name2 == "View");
                        }
                    }
                }
            }

            return(listOfFunctionPermissions);
        }
Exemplo n.º 2
0
        private int GetFunctionMappingID(string functionCode, string operasID)
        {
            BaseDao            context         = new BaseDao();
            sy_functionmapping functionMapping = context.sy_functionmapping.Where(c => c.OperID == operasID && c.FunctionID == functionCode).FirstOrDefault();

            if (functionMapping != null)
            {
                return(functionMapping.ID);
            }
            return(0);
        }
Exemplo n.º 3
0
        private int DeleteSys_functionMapping(sy_functionmapping deleteSyS_functionmapping)
        {
            int mappID = 0;

            using (BaseDao context = new BaseDao())
            {
                sy_functionmapping deletesy_functionmapping = context.sy_functionmapping.FirstOrDefault(c => c.OperID == deleteSyS_functionmapping.OperID && c.FunctionID == deleteSyS_functionmapping.FunctionID);
                mappID = deleteSyS_functionmapping.ID;
                if (deletesy_functionmapping != null)
                {
                    context.sy_functionmapping.DeleteObject(deletesy_functionmapping);
                    mappID = context.Saves();
                }
            }
            return(mappID);
        }
Exemplo n.º 4
0
        private int InsertSys_functionMapping(sy_functionmapping insertDto)
        {
            int mappID = 0;

            using (BaseDao context = new BaseDao())
            {
                sy_functionmapping newFunctionMapping = new sy_functionmapping()
                {
                    OperID     = insertDto.OperID,
                    FunctionID = insertDto.FunctionID
                };
                context.sy_functionmapping.AddObject(newFunctionMapping);
                mappID = context.Saves();
            }
            return(mappID);
        }