//----------------------------------- PREMIUM USERS ------------------------------------------------------- public void GetPremiumUsers() { try { int numOfUsers = Users.Count; int min = Convert.ToInt32(numOfUsers * 0.8); int max = Convert.ToInt32(numOfUsers * 0.9); int numOfPremiumUsers = rand.Next(min, max); for (int i = 0; i < numOfPremiumUsers; i++) { var current_user = Users.RandomItem(); if (!PremiumUsers.Contains(current_user)) { PremiumUsers.Add(current_user); } } } catch (Exception e) { throw e; } }
public ManageRolesViewModel(TomasosContext context) { var RegUsers = (from k in context.Kund join i in context.AspNetUsers on k.IdentityId equals i.Id join ur in context.AspNetUserRoles on i.Id equals ur.UserId join r in context.AspNetRoles on ur.RoleId equals r.Id where r.Name == "Regular" select k).ToList(); var PremUsers = (from k in context.Kund join i in context.AspNetUsers on k.IdentityId equals i.Id join ur in context.AspNetUserRoles on i.Id equals ur.UserId join r in context.AspNetRoles on ur.RoleId equals r.Id where r.Name == "Premium" select k).ToList(); foreach (var item in RegUsers) { RegularUsers.Add(new SelectListItem(item.Namn, item.KundId.ToString())); } foreach (var item in PremUsers) { PremiumUsers.Add(new SelectListItem(item.Namn, item.KundId.ToString())); } }