Exemple #1
0
        public IEnumerable <RoleModel> GetRoles(Dictionary <string, string> sorting, Dictionary <string, string> filter)
        {
            string Name = filter.ContainsKey("Name") ? filter["Name"] : string.Empty;
            IEnumerable <CU_Role> Roles = RolesList.Where(x => x.Name.Trim().ToLower().Contains(string.IsNullOrEmpty(Name.Trim().ToLower()) ? "" : Name.Trim().ToLower())).OrderByDescending(x => x.ID);

            if (sorting.ContainsKey("ID"))
            {
                if (sorting["ID"] == "asc")
                {
                    Roles = Roles.OrderBy(c => c.ID);
                }
                else
                {
                    Roles = Roles.OrderByDescending(c => c.ID);
                }
            }

            if (sorting.ContainsKey("Name"))
            {
                if (sorting["Name"] == "asc")
                {
                    Roles = Roles.OrderBy(c => c.Name);
                }
                else
                {
                    Roles = Roles.OrderByDescending(c => c.Name);
                }
            }

            var data = Mapper.Map <IEnumerable <CU_Role>, IEnumerable <RoleModel> >(Roles);

            return(data);
        }
        public RoleProgramModel GetRoleProgramByRoleAndProgramId()
        {
            var ProgramID = System.Configuration.ConfigurationManager.AppSettings["ProgramID"];
            var RoleID    = System.Configuration.ConfigurationManager.AppSettings["ResearcherID"];

            var data   = RolesList.Where(x => x.IdProgram == int.Parse(ProgramID) && x.IdRole == int.Parse(RoleID)).FirstOrDefault();
            var result = Mapper.Map <CU_Role_Program, RoleProgramModel>(data);

            return(result);
        }