static void Main(string[] args) { Student Sergei = new Student("Sergei Mikovoz", new int[] { 3, 4, 5 }); Student Vsevolod = new Student("Vsevolod Drobish", new int[] { 7, 6, 4, 3 }); Student Artem = new Student("Artem Zagorovskiy", new int[] { 9, 8, 7, 6, 5 }); Student[] studs = new Student[] { Sergei, Vsevolod, Artem }; Group.Group group = new Group.Group(2, studs); System.Console.WriteLine($"Group: {group.AverageScore()}"); System.Console.WriteLine($"Sergei : {Sergei.AverageScore()}"); System.Console.ReadKey(); }
private static void InsertUserToAddmins(string userName) { using (var scope = new TransactionScope()) { using (GroupsEntities context = new GroupsEntities()) { var adminGroup = new Group { GroupName = "Admins" }; if (context.Groups.Count(x => x.GroupName == "Admins") == 0) { context.Groups.Add(adminGroup); context.SaveChanges(); scope.Complete(); } else { if (context.Users.Count(x => x.UserName == userName) > 0) { Console.WriteLine("User already exists."); scope.Dispose(); } var currentgroup = context.Groups .Where(x => x.GroupName == "Admins").First(); var newUser = new User() { UserName = userName, GroupID = currentgroup.GroupID }; context.Users.Add(newUser); context.SaveChanges(); scope.Complete(); } } } }