private static void AddStudentsFromFile( TextWriter writer, string filename, IStudentStore students ) { try { using (StreamReader sr = File.OpenText(filename)) { var header = Tokenize(sr.ReadLine()); if (!IsValidHeaderRow(header)) { writer.WriteLine("Invalid header \n'{0}'.\nPlease correct it and try again.", header); return; } while (!sr.EndOfStream) { var line = sr.ReadLine(); var row = Tokenize(line); if (!IsValidStudentRow(header.Length, row)) { writer.WriteLine("Invalid row \n'{0}'.\nPlease correct it and try again.", line); return; } var student = ReadRowAsStudent(row); students.Add(student); } } } catch (Exception ex) { writer.WriteLine("Error while reading the file: {0}", ex.Message); } }
public async Task <IActionResult> ByGroup( int cid, AddTeamByGroupModel model, [FromServices] IStudentStore store) { var cls = await store.FindClassAsync(model.GroupId); if (cls == null) { return(NotFound()); } var affs = await Store.ListAffiliationAsync(cid, false); var cats = await Store.ListCategoryAsync(cid); var aff = affs.SingleOrDefault(a => a.AffiliationId == model.AffiliationId); var cat = cats.SingleOrDefault(c => c.CategoryId == model.CategoryId); if (aff == null || cat == null) { return(NotFound()); } var stus = await store.ListStudentsAsync(cls); var stu = stus.ToLookup(s => new { s.Id, s.Name }); var uids = await Store.ListMemberUidsAsync(cid); foreach (var item in stu) { var lst = item.Where(s => s.IsVerified ?? false); if (model.AddNonTemporaryUser) { lst = lst.Where(s => s.Email == null); } var users = lst.Select(s => s.UserId.Value) .Where(i => !uids.Contains(i)) .ToHashSet(); await Store.CreateAsync( uids : users.Count > 0?users.ToArray() : null, team : new Team { AffiliationId = model.AffiliationId, Status = 1, CategoryId = model.CategoryId, ContestId = Contest.ContestId, TeamName = $"{item.Key.Id}{item.Key.Name}", }); } StatusMessage = "Import success."; return(RedirectToAction(nameof(List))); }
public async Task <IActionResult> ByGroup(int cid, [FromServices] IStudentStore store) { ViewBag.Aff = await Store.ListAffiliationAsync(cid, false); ViewBag.Cat = await Store.ListCategoryAsync(cid); ViewBag.Class = await store.ListClassAsync(); return(Window(new AddTeamByGroupModel { AffiliationId = 1, CategoryId = 3, AddNonTemporaryUser = true })); }
public UserManager( IUserStore <User> store, IStudentStore db, IOptions <IdentityOptions> optionsAccessor, IPasswordHasher <User> passwordHasher, IEnumerable <IUserValidator <User> > userValidators, IEnumerable <IPasswordValidator <User> > passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger <UserManager> logger) : base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger) { studentStore = db; }
public StudentConsole(IStudentStore obj) { studentobj = obj; }
public StudentsController(IStudentStore StudentStore, ILogger <StudentsController> Logger) { _StudentStore = StudentStore; _Logger = Logger; }
private static void BranchMenu( TextReader reader, TextWriter writer, ClearOutput clearOut, InteractiveIO io, IStudentStore students ) { clearOut(); writer.WriteLine("Total students: {0}\n", students.Length); writer.WriteLine("Which task would you like to execute?"); writer.WriteLine("{0}) Add a new student", (int)MenuChoice.AddStudent); writer.WriteLine("{0}) Read students from file", (int)MenuChoice.ReadStudentsFile); writer.WriteLine("{0}) Print results of students", (int)MenuChoice.PrintResults); writer.WriteLine("{0}) Benchmark", (int)MenuChoice.Benchmark); writer.WriteLine("{0}) Exit program\n", (int)MenuChoice.Exit); writer.Write("Menu choice: "); #pragma warning disable IDE0018 // Inline variable declaration int menuChoice; #pragma warning restore IDE0018 // Inline variable declaration if (!int.TryParse(reader.ReadLine(), out menuChoice)) { writer.WriteLine("Error parsing the choice, please try again..."); reader.Read(); } else { switch (menuChoice) { case (int)MenuChoice.AddStudent: { var student = ReadStudentInteractive(io); students.Add(student); break; } case (int)MenuChoice.ReadStudentsFile: { var filename = io.ReadLineInteractive("File name: "); AddStudentsFromFile(writer, filename, students); writer.WriteLine("Press any key to continue."); reader.Read(); break; } case (int)MenuChoice.PrintResults: { var sortedStudents = students.All() .OrderBy(x => x.surname) .ThenBy(x => x.name); StudentSummaryPrinter.PrintSummary(writer, sortedStudents); reader.Read(); break; } case (int)MenuChoice.Benchmark: { BenchmarkSuite(reader, writer); reader.Read(); break; } case (int)MenuChoice.Exit: return; default: writer.WriteLine("Wrong choice, please try again..."); reader.Read(); break; } } BranchMenu(reader, writer, clearOut, io, students); }
public StudentService(IStudentStore studentStore, TelemetryClient telemetryClient, ILogger <StudentService> logger) { _studentStore = studentStore; _telemetryClient = telemetryClient; _logger = logger; }
public GroupsController(IStudentStore store) => Store = store;
public StudentsesManager(IStudentStore Students, ICoursesStore Courses) { _Students = Students; _Courses = Courses; }