private void CreateEgeTasksTopics(ExamAppDbContext examAppDbContext, List <TaskTopic> tasksTopics) { var rm = new ResourceManager("WebApiTest4.Parsing.Topics", Assembly.GetExecutingAssembly()); for (int i = 1; i <= countOfTopics; i++) { var topic = tasksTopics.FirstOrDefault(x => x.Id == i); if (topic != null) { topic.Name = rm.GetString("s" + i); if (i < freeAnswerTasksStartsCount) { topic.PointsPerTask = 1; topic.IsShort = true; topic.Code = "B" + i; } else { topic.Code = "C" + (i - freeAnswerTasksStartsCount + 1); topic.PointsPerTask = 3; if (i == 25) { topic.PointsPerTask = 2; } if (i == 27) { topic.PointsPerTask = 4; } } } } }
protected override void InitializeController() { base.InitializeController(); if (this.User.IsAuthenticated) { this.ViewModel["anonymousDisplay"] = "none"; this.ViewModel["userDisplay"] = "flex"; using (var db = new ExamAppDbContext()) { this.Profile = db .Users .First(u => u.Email == this.User.Name); this.ViewModel["userDisplay"] = "flex"; if (IsAdmin) { this.ViewModel["adminDisplay"] = "flex"; } else { this.ViewModel["adminDisplay"] = "none"; } } } }
static Launcher() { using (var db = new ExamAppDbContext()) { db.Database.Migrate(); } }
public override void Load() { var context = new ExamAppDbContext(); this.Bind <ITrainsService>().To <TrainsService>().WithConstructorArgument("context", context); this.Bind <ITaskService>().To <TaskServiceImpl>().WithConstructorArgument("context", context); this.Bind <IUserService>().To <UserServiceImpl>().WithConstructorArgument("context", context); this.Bind <ITopicService>().To <TopicServiceImpl>().WithConstructorArgument("context", context); this.Bind <ISchoolService>().To <SchoolServiceImpl>().WithConstructorArgument("context", context); this.Bind <ISolvedTasksService>().To <SolvedTasksServiceImpl>().WithConstructorArgument("context", context); }
private void AddBindings() { var context = new ExamAppDbContext(); kernel.Bind <IHttpController>().To <AccountController>(); kernel.Bind <ExamAppDbContext>().ToSelf(); kernel.Bind <ITaskService>().To <TaskServiceImpl>().WithConstructorArgument("context", context); kernel.Bind <IUserService>().To <UserServiceImpl>().WithConstructorArgument("context", context); kernel.Bind <ITopicService>().To <TopicServiceImpl>().WithConstructorArgument("context", context); kernel.Bind <ISchoolService>().To <SchoolServiceImpl>().WithConstructorArgument("context", context); kernel.Bind <ISolvedTasksService>().To <SolvedTasksServiceImpl>().WithConstructorArgument("context", context); }
public async Task AddNewTasks(ExamAppDbContext examAppDbContext) { var exam = examAppDbContext.Exams.OfType <EgeExam>().FirstOrDefault(); var existingTopics = examAppDbContext.TaskTopics.ToList(); var existingTasks = examAppDbContext.Tasks.ToList(); var createdTasksTopics = new List <TaskTopic>(); var createdTasks = new List <ExamTask>(); var config = Configuration.Default.WithDefaultLoader(); const int numberOfVariants = 20; for (int i = 1; i <= numberOfVariants; i++) { var address = "http://kpolyakov.spb.ru/school/ege/gen.php?B=on&C=on&action=viewVar&varId=" + i; var document = await BrowsingContext.New(config).OpenAsync(address).ConfigureAwait(false); var cellSelector = "td.topicview script"; var cells = document.QuerySelectorAll(cellSelector); const string numberPrefix = "№ "; const string textPrexfix = "changeImageFilePath('"; foreach (var cell in cells) { var result = cell.TextContent; var firstOrDefault = cell.ParentElement.ParentElement.QuerySelectorAll("td.egeno span").FirstOrDefault(); if (firstOrDefault != null) { int orderNum = int.Parse(firstOrDefault.TextContent); int numStartPoint = result.IndexOf(numberPrefix) + numberPrefix.Length; int textStartPoint = result.IndexOf(textPrexfix) + textPrexfix.Length; if (existingTopics.All(x => x.Number != orderNum)) { var newTopic = new TaskTopic() { Exam = exam, Name = "DefaultName" + orderNum, Number = orderNum, PointsPerTask = 0 }; createdTasksTopics.Add(newTopic); existingTopics.Add(newTopic); } var topic = existingTopics.FirstOrDefault(x => x.Number == orderNum); var number = int.Parse(result.Substring(numStartPoint, result.IndexOf(")") - numStartPoint)); if (!existingTasks.Any(x => x.Number == number)) { var newTask = new ExamTask() { TaskTopic = topic, Number = number, Text = result.Substring(textStartPoint, result.LastIndexOf("\') );") - textStartPoint), Answer = document .QuerySelectorAll("table.varanswer tr td.egeno") .Where( x => int.Parse(x.TextContent.Substring(0, x.TextContent.Length - 1)) == orderNum) .Next("td.answer") .FirstOrDefault()?.TextContent }; createdTasks.Add(newTask); existingTasks.Add(newTask); } } } } examAppDbContext.TaskTopics.AddRange(createdTasksTopics); examAppDbContext.Tasks.AddRange(createdTasks); CreateEgeTasksTopics(examAppDbContext, existingTopics); examAppDbContext.SaveChanges(); }
public TaskServiceImpl(ExamAppDbContext context) { _dbContext = context; }
public RoleStoreIntPk(ExamAppDbContext context) : base(context) { }
public UserStoreIntPk(ExamAppDbContext context) : base(context) { }
public SchoolServiceImpl(ExamAppDbContext context) { _context = context; }
public UserService() { this.db = new ExamAppDbContext(); }
public FlightService() { this.db = new ExamAppDbContext(); }
public TopicServiceImpl(ExamAppDbContext context) { _context = context; }
public UserServiceImpl(ExamAppDbContext context) { _context = context; }
public TrainsService(ExamAppDbContext context) { _dbContext = context; }
public SolvedTasksServiceImpl(ExamAppDbContext context) { _context = context; }