public List <UseUserRoleGetModel> GetAllRoles(int id) { List <UseUserRoleGetModel> result = new List <UseUserRoleGetModel>(); var list = context.UserUserRoles.Include(u => u.UserRole).Include(u => u.User) .Where(u => u.UserId == id).OrderBy(r => r.StartTime); foreach (UserUserRole us in list) { result.Add(UseUserRoleGetModel.ToUseUserRoleGetModel(us)); } return(result); }
public IEnumerable <UseUserRoleGetModel> GetHistoryById(int id) { List <UserUserRole> histories = context.Users .Include(x => x.UserUserRoles) .ThenInclude(x => x.UserRole) .FirstOrDefault(u => u.Id == id).UserUserRoles.ToList(); List <UseUserRoleGetModel> returnList = new List <UseUserRoleGetModel>(); foreach (UserUserRole history in histories) { returnList.Add(UseUserRoleGetModel.ToUseUserRoleGetModel(history)); } var list = returnList.OrderBy(x => x.AllocatedAt); return(list); }