public async Task <IActionResult> Edit(int id, [Bind("Id,MaxRDW,MaxNonRDW")] Maxima maxima) { if (id != maxima.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(maxima); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MaximaExists(maxima.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(maxima)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,MaxRDW,MaxNonRDW,SiteHasBeenLocked")] Maxima maxima) { if (id != maxima.Id) { return(NotFound()); } if (ModelState.IsValid) { var dbmaxima = await _context.Maxima.SingleOrDefaultAsync(t => t.Id == maxima.Id); try { dbmaxima.MaxRDW = maxima.MaxRDW; dbmaxima.MaxNonRDW = maxima.MaxNonRDW; dbmaxima.SiteHasBeenLocked = maxima.SiteHasBeenLocked; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MaximaExists(maxima.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(HomeController.Index), "Home")); } return(View(maxima)); }
// GET: Maxima public async Task <IActionResult> Index() { var maxima = await _context.Maxima.SingleOrDefaultAsync(); if (maxima == null) { // if maxima table empty create placeholder record maxima = new Maxima { MaxRDW = 0, MaxNonRDW = 0 }; _context.Maxima.Add(maxima); await _context.SaveChangesAsync(); } int confirmedUserCount = await ApplicationUser.ConfirmedUserCountAsync(_context); int unconfirmedUserCount = await ApplicationUser.UnconfirmedUserCountAsync(_context); int confirmedRdwUserCount = await ApplicationUser.ConfirmedRdwUserCountAsync(_context); int confirmedNonRdwUserCount = await ApplicationUser.ConfirmedNonRdwUserCountAsync(_context); int rdwUserCount = await ApplicationUser.RdwUserCountAsync(_context); int nonRdwUserCount = await ApplicationUser.NonRdwuserCountAsync(_context); ViewBag.ConfirmedUserCount = confirmedUserCount.ToString(); ViewBag.UnconfirmedUserCount = unconfirmedUserCount.ToString(); ViewBag.ConfirmedRdwUserCount = confirmedRdwUserCount.ToString(); ViewBag.ConfirmedNonRdwUserCount = confirmedNonRdwUserCount.ToString(); ViewBag.UnconfirmedRdwUserCount = rdwUserCount - confirmedRdwUserCount; ViewBag.UnconfirmedNonRdwUserCount = nonRdwUserCount - confirmedNonRdwUserCount; List <ApplicationUser> users = await _context.ApplicationUsers .Include(t => t.ApplicationUserTijdvakken) /* this is to filter older users that did not have a datecreated field as they where created before adding the field */ .Where(t => t.DateCreated > new System.DateTime(2017, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)) .OrderByDescending(t => t.DateCreated) .Take(20) .ToListAsync(); List <ApplicationUser> unverifiedUsers = await _context.ApplicationUsers .Include(t => t.ApplicationUserTijdvakken) .Where(t => t.EmailConfirmed == false) .OrderByDescending(t => t.DateCreated) .ToListAsync(); maxima.LastCreatedUsers = users; maxima.UnverifiedUsers = unverifiedUsers; return(View(maxima)); }
// GET: Maxima public async Task <IActionResult> Index() { var maxima = await _context.Maxima.SingleOrDefaultAsync(); if (maxima == null) { // if maxima table empty create placeholder record maxima = new Maxima { MaxRDW = 0, MaxNonRDW = 0 }; _context.Maxima.Add(maxima); await _context.SaveChangesAsync(); } return(View(maxima)); }
public static Maxima Z_Info() { Maxima ret = new Maxima(); ret.f_max = 2; ret.k_max = 2; ret.a_max = 2; ret.e_max = 2; ret.r_max = 2; ret.mp_max = 2; ret.s_max = 2; ret.pit_max = 2; ret.o_max = 2; ret.m_max = 2; return(ret); }
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, SiteNotLockedRequirement requirement) { if (context.User.IsInRole("Admin") || requirement.ActionAllowed) { context.Succeed(requirement); } else { ApplicationDbContext dbcontext = scopedServiceProvider.Get(); Maxima maxima = await dbcontext.Maxima.FirstOrDefaultAsync(); if (!maxima.SiteHasBeenLocked) { context.Succeed(requirement); } } }
static void Main(string[] args) { Expression <Func <double, double> > f = x => 3 * Math.Pow(x, 2) + 2 * x + Math.Pow(Math.Cos(x), 2) + Math.Pow(Math.Sin(x), 2); Expression <Func <double, double> > g = x => 2 * x + 5 * 2; Expression <Func <double, double, double> > h = (y, z) => y + z; Console.WriteLine(f.Times(g).Simplify()); Console.WriteLine(f.Over(g).Simplify()); Maxima.GnuPlot(@"plot x+5*cos(x)"); Maxima.GnuPlot(@" set parametric set pm3d depthorder hidden3d set isosamples 30, 20 splot [-pi:pi][-pi:pi] cos(u)*(cos(v)+3), sin(u)*(cos(v)+3), sin(v) w pm "); Console.ReadLine(); }
public async Task <IActionResult> Index() { Maxima maxima = await _context.Maxima.FirstOrDefaultAsync(); var user = await _userManager.GetUserAsync(User); if (_signInManager.IsSignedIn(User) && user == null) { // Workaround for a bug in the EF Identity framework, // if an identity cookie was used before dropping the database and the you start the app (which creates a new database) without logging out before the drop, // you get a situation where EF SignInManager thinks you are signed in, but the UserManager.GetUserAsync will return an empty string (as the cookie refers to a now deleted user). Which gives errors all over the place // I have tried several alternatives to fix it, but deleting the Identity cookie seems the only solution HttpContext.Response.Cookies.Delete(".AspNetCore.Identity.Application"); return(RedirectToAction(nameof(Index))); } else { ViewBag.SiteHasBeenLocked = maxima.SiteHasBeenLocked; return(View()); } }
public async Task <IActionResult> SelectSessies() { string id = _userManager.GetUserId(User); if (id == null) { return(NotFound()); } ApplicationUser user = await _context.ApplicationUsers .Include(c => c.ApplicationUserTijdvakken) .ThenInclude(atv => atv.Sessie) .ThenInclude(t => t.Track) .Include(c => c.ApplicationUserTijdvakken) .ThenInclude(atv => atv.Sessie) .ThenInclude(t => t.Ruimte) .Include(c => c.ApplicationUserTijdvakken) .ThenInclude(atv => atv.Sessie) .ThenInclude(t => t.SessieTijdvakken) .Include(c => c.ApplicationUserTijdvakken) .ThenInclude(t => t.Tijdvak) .SingleOrDefaultAsync(m => m.Id == id); if (user == null) { return(NotFound()); } SelectSessies model = new SelectSessies(); model.ApplicationUserTijdvakken = user.ApplicationUserTijdvakken.OrderBy(atv => atv.Tijdvak.Order).ToList(); Maxima maxima = await _context.Maxima.FirstOrDefaultAsync(); ViewBag.isSiteLocked = maxima.SiteHasBeenLocked; return(View(model)); }