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)); }
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)); }