Esempio n. 1
0
        public RoleModelDA GetRoleById(int id)
        {
            var role = _context.Roles.FirstOrDefault(u => u.Id == id);

            if (role == null)
            {
                return(RoleMapDA.RoleToRoleModelDA(role));
            }
            else
            {
                throw new NullReferenceException("The role isn't exist.");
            }
        }
Esempio n. 2
0
        public RoleModelDA GetRoleByName(string name)
        {
            var role = _context.Roles.FirstOrDefault(u => u.Name == name);

            if (role != null)
            {
                return(RoleMapDA.RoleToRoleModelDA(role));
            }
            else
            {
                throw new NullReferenceException("The role isn't exist.");
            }
        }
Esempio n. 3
0
        public List <RoleModelDA> GetAllRoles()
        {
            var roles = new List <RoleModelDA>();

            _context.Roles.ToList().ForEach(s => roles.Add(RoleMapDA.RoleToRoleModelDA(s)));

            if (roles != null)
            {
                return(roles);
            }
            else
            {
                throw new Exception("There are no roles.");
            }
        }