public AllContestantsViewModel() { var context = new TMSContext(); Contestants = new ObservableCollection <Contestant>(context.Contestants); RaisePropertyChangedEvent("Contestants"); }
public async Task <bool> Execute(TMSContext context) { var listings = new List <Listing>(); var termNodes = await GetTermNodes(); foreach (var termNode in termNodes) { var collegePaths = await GetCollegePaths(termNode, context); foreach (var collegePath in collegePaths) { var departmentPaths = await GetDepartmentPaths(collegePath); foreach (var departmentPath in departmentPaths) { var classNodes = await GetClassNodes(departmentPath); foreach (var classNode in classNodes) { await PopulateListings(classNode); } } } } SaveListings(context); return(true); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TMSContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "areas", pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}" ); endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); DbInitializer.Seed(context); }
/// <summary> /// Default constructor, creating a new default context /// </summary> /// <summary> /// Constructor specifying the context and entity on which to act /// </summary> /// <param name="ctx">The DbContext to use</param> /// <param name="entity">The entity on which to perform the action</param> public DataAction(TMSContext ctx, T entity, ILogger <TMSContext> logger) { Context = ctx; _logger = logger; Repository = new Repository <T>(ctx, _logger); Entity = entity; }
public async Task <IEnumerable <string> > GetCollegePaths(HtmlNode termNode, TMSContext context) { using (var client = new HttpClient()) { Term term = context.Terms.FirstOrDefault(x => x.LookupLabel == termNode.InnerText.Replace(" ", "")); if (term == null) { term = new Term() { TermName = termNode.InnerText.Trim(), LookupLabel = termNode.InnerText.Replace(" ", "") }; Terms.Add(term); LastTerm = term; } var termPath = termNode.Attributes.First(x => x.Name == "href").Value.Replace("amp;", ""); var termListing = await client.GetAsync(Constants.BASE_PATH + termPath); if (!termListing.IsSuccessStatusCode) { throw new Exception("Failed to get College Paths (Step 2)"); } var termContent = await termListing.Content.ReadAsStringAsync(); var listingDocument = new HtmlDocument(); listingDocument.LoadHtml(termContent); var collegeNodes = listingDocument.DocumentNode.SelectNodes(Constants.COLLEGE_PATHS); return(collegeNodes.Select(x => x.Attributes.First(x => x.Name == "href").Value.Replace("amp;", ""))); } }
public ShowAllContestantsViewModel(int tournamentId) { var context = new TMSContext(); var queryContestantsInTournament = (from c in context.Contestants where c.TournamentId == tournamentId select c).ToList(); Contestants = new ObservableCollection <Contestant>(queryContestantsInTournament); RaisePropertyChangedEvent("Contestants"); }
protected override void OnStartup(StartupEventArgs e) { using (var db = new TMSContext()) { base.OnStartup(e); var init = new TMSContextInitializer(); Database.SetInitializer(init); init.InitializeDatabase(db); } }
public ExploreDatabaseViewModel() { var context = new TMSContext(); WeightClasses = new ObservableCollection <WeightClass>(context.WeightClasses); RaisePropertyChangedEvent("WeightClasses"); AgeClasses = new ObservableCollection <AgeClass>(context.AgeClasses); RaisePropertyChangedEvent("AgeClasses"); Contestants = new ObservableCollection <Contestant>(context.Contestants); RaisePropertyChangedEvent("Contestants"); }
public Tournament FindTournamentById(int id) { try { var context = new TMSContext(); return((from t in context.Tournaments where t.TournamentId == id select t).ToList()[0]); } catch (Exception e) { MessageBox.Show("ERROR FINDING TOURNAMENT!" + e.Message); return(null); } }
public void AddNewTournament() { try { TMSContext context = new TMSContext(); //validate ID var queryID = (from t in context.Tournaments where t.TournamentId == _tournament.TournamentId select t) .ToList(); //TODO: VALIDATION if (queryID.Count >= 1) { OutputMessage = "A tournament with this ID already exists in the database!"; MessageBox.Show(OutputMessage, "ERROR", MessageBoxButtons.OK); } var queryName = (from t in context.Tournaments where t.Name == _tournament.Name select t).ToList(); if (queryName.Count >= 1) { OutputMessage = "A tournament with this name already exists in the database!"; MessageBox.Show(OutputMessage, "ERROR", MessageBoxButtons.OK); } else { context.Tournaments.AddOrUpdate(_tournament); context.SaveChanges(); OutputMessage += "\nSuccessfully added a new tournament to the database!\n"; OutputMessage += _tournament.GetTournamentDataString(); MessageBox.Show(OutputMessage, "SUCCESS"); } } catch (Exception e) { OutputMessage += "\nERROR adding new tournament to database!\nErrormessage = " + e.Message + "\n"; OutputMessage += _tournament.GetTournamentDataString(); MessageBox.Show(OutputMessage, "ERROR"); } CleanUp(); Messenger.Default.Send(new ChangeView() { ViewName = "Tournaments" }); }
public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl) { string provider = null; string providerUserId = null; if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId)) { return(RedirectToAction("Manage")); } if (ModelState.IsValid) { // Insert a new user into the database using (TMSContext db = new TMSContext()) { UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower()); // Check if user already exists if (user == null) { // Insert name into the profile table db.UserProfiles.Add(new UserProfile { UserName = model.UserName }); db.SaveChanges(); OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName); OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name."); } } } ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName; ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public void AddNewContestant() { try { TMSContext context = new TMSContext(); //TODO: VALIDATION context.Contestants.AddOrUpdate(_contestant); context.SaveChanges(); OutputMessage += "\nSuccessfully added a new contestant to the database!\n"; RaisePropertyChangedEvent("OutputMessage"); OutputMessage += _contestant.GetContestantDataString(); RaisePropertyChangedEvent("OutputMessage"); } catch (Exception e) { OutputMessage += "\nERROR adding new contestant to database!\nErrormessage = " + e.Message + "\n"; RaisePropertyChangedEvent("OutputMessage"); OutputMessage += _contestant.GetContestantDataString(); RaisePropertyChangedEvent("OutputMessage"); } }
public async Task SaveListings(TMSContext context) { foreach (var listing in Listings) { var oldListing = context.Listings.FirstOrDefault(x => x.CRN == listing.CRN && x.Term.TermID == listing.Term.TermID); if (oldListing != null && !oldListing.IsEqual(listing)) { oldListing.Subject = listing.Subject; oldListing.CourseNumber = listing.CourseNumber; oldListing.InstructionType = listing.InstructionType; oldListing.InstructionMethod = listing.InstructionMethod; oldListing.Section = listing.Section; oldListing.MaxEnroll = listing.MaxEnroll; oldListing.Enroll = listing.Enroll; oldListing.CourseTitle = listing.CourseTitle; oldListing.Times = listing.Times; oldListing.Instructor = listing.Instructor; oldListing.ModifiedDate = DateTime.Now; Updated += 1; } else { New += 1; context.Add(listing); } } foreach (var term in Terms) { if (context.Terms.Any(x => x.LookupLabel == term.LookupLabel)) { var oldTerm = context.Terms.First(x => x.LookupLabel == term.LookupLabel); context.Entry(oldTerm).CurrentValues.SetValues(term); } else { context.Add(term); } } context.SaveChanges(); }
public SimpleMembershipInitializer() { Database.SetInitializer <TMSContext>(null); try { using (var context = new TMSContext()) { if (!context.Database.Exists()) { // Create the SimpleMembership database without Entity Framework migration schema ((IObjectContextAdapter)context).ObjectContext.CreateDatabase(); } } WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); } catch (Exception ex) { throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex); } }
public PlayersController(TMSContext context, IWebHostEnvironment env) { _context = context; _env = env; }
public HomeController(ILogger <HomeController> logger, TMSContext context) { _logger = logger; _tmsContext = context; }
public ClassAdminsController(TMSContext context) { _context = context; }
public TrainersController(TMSContext context) { _context = context; }
public Requests2Controller(TMSContext context) { _context = context; }
public RequestsController(TMSContext context, IRequestServices requestServices) { _context = context; _requestServices = requestServices; }
public RequestRepository(TMSContext context) : base(context) { }
public TMSController(TMSContext context) { _tmsContext = context; }
public TraineeRepository(TMSContext context) : base(context) { }
/// <summary> /// Constructor specifying the context in which the action will be performed (otherwise it will create a new default context for use in the repository) /// </summary> /// <param name="ctx"></param> public DataAction(TMSContext ctx, ILogger <TMSContext> logger) { _logger = logger; Context = ctx; Repository = new Repository <T>(ctx, logger); }
public ClassAdminRepository(TMSContext context) : base(context) { }
public ClassBatchRepository(TMSContext context) : base(context) { }
public StadiumsController(TMSContext context, IWebHostEnvironment env) { _context = context; _env = env; }
/// <summary> /// Default constructor creating a new DbContext and setting Autosave to true /// </summary> public Repository(TMSContext ctx, ILogger <TMSContext> logger) { _logger = logger; _ctx = ctx; Autosave = true; }
public TraineesController(TMSContext context, ITraineeServices traineeServices) { _context = context; _traineeServices = traineeServices; }
public UnitOfWork(TMSContext cont, ILogger <TMSContext> logger) { _logger = logger; _context = cont; }