Exemple #1
0
        public ActionResult <List <RoleResourceModel> > GetRoles()
        {
            var data = RoleMgr.Roles.ToList();

            List <RoleResourceModel> All_Roles = new List <RoleResourceModel>();

            foreach (var role in data)
            {
                RoleResourceModel user_role = new RoleResourceModel
                {
                    RoleId      = role.Id,
                    Name        = role.Name,
                    Description = role.Description,
                    DateCreated = role.DateCreated
                };
                All_Roles.Add(user_role);
            }
            ;
            return(Ok(All_Roles));
        }
Exemple #2
0
        public ActionResult <RoleResourceModel> GetRole(Guid?id)
        {
            if (id == null)
            {
                return(BadRequest(new { Error = "ID can not be null" }));
            }

            var role = RoleMgr.Roles.Where(f => f.Id == id).FirstOrDefault();

            if (role == null)
            {
                return(NotFound());
            }

            RoleResourceModel user_role = new RoleResourceModel
            {
                RoleId      = role.Id,
                Name        = role.Name,
                Description = role.Description,
                DateCreated = role.DateCreated
            };

            return(Ok(user_role));
        }