public async Task <List <TEntity> > GetAllAsync() { using (var db = new BPContext()) { return(await db.Set <TEntity>().ToListAsync()); } }
public async Task <TEntity> GetByIdAsync(int id) { using (var db = new BPContext()) { return(await db.Set <TEntity>().FindAsync(id)); } }
public async Task <List <Category> > GetAllCategoryWithPostCount() { using (var db = new BPContext()) { return(await db.Categories.Include(i => i.PostCategories).ToListAsync()); } }
async Task VerifyTask(BPContext context, bool sandbox) { var pairs = ParseIPN(context.RequestBody); var url = sandbox ? $"https://test.bitpay.com/invoices/{pairs["invoice_id"]}" : $"https://bitpay.com/invoices/{pairs["invoice_id"]}"; await ProcessVerificationResponse(JsonConvert.DeserializeObject <BPModel>(GetUrl(url))); }
public async Task <Category> GetCategoryByName(string name) { using (var db = new BPContext()) { return(await db.Categories.Where(i => i.Name == name).FirstOrDefaultAsync()); } }
public async Task <User> CheckUserAsync(User user) { using (var db = new BPContext()) { return(await db.Users.Where(i => i.Email == user.Email && i.Password == user.Password).FirstOrDefaultAsync()); } }
public async Task <List <Post> > GetAllPostWithCategories() { using (var db = new BPContext()) { return(await db.Posts.Include(i => i.PostCategories).ThenInclude(i => i.Category).ToListAsync()); } }
public async Task UpdateAsync(TEntity entity) { using (var db = new BPContext()) { db.Set <TEntity>().Update(entity); await db.SaveChangesAsync(); } }
public static async System.Threading.Tasks.Task ReCalculateAllTotalsAsync(BPContext context) { var scoring = context.ScoringSystem.AsNoTracking().ToArray(); foreach (var p in context.Performances) { CalculateTotalPoints(p, scoring.FirstOrDefault(g => g.Position == p.Position)); } var result = await context.SaveChangesAsync(); }
public static void CalculateTotal(Performance p, BPContext context) { var scoring = context.ScoringSystem.Where(g => g.Position == p.Position) .FirstOrDefault(); var match = context.Matches.Where(m => m.ID == p.MatchID).SingleOrDefault(); p.GoalsConceeded = match.GoalsConceeded; p.CleanSheet = p.GoalsConceeded > 0 ? false : true; CalculateTotalPoints(p, scoring); }
public void MyTestMethod() { using (var context = new BPContext()) { var accounts = context.Matches .AsNoTracking() .Include(g => g.Oposition) .Include(g => g.Performances) .ToList(); } }
public void Test1() { var options = new DbContextOptionsBuilder <BPContext>() .UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=BillericayPioneers;Trusted_Connection=True;MultipleActiveResultSets=true") .Options; using (var context = new BPContext(options)) { var players = context.Players.Include(g => g.Performances) .ToArray(); } }
public static bool IsValidUser(User user, BPContext context) { if (string.IsNullOrEmpty(user?.Username) || string.IsNullOrEmpty(user?.Password)) { return(false); } else { return(context.Users.Any(g => g.Username == user.Username && g.Password == ComputeHash(user.Password))); } }
public static async Task AddAsync(User user, BPContext context) { if (string.IsNullOrEmpty(user?.Username) || string.IsNullOrEmpty(user?.Password)) { throw new Exception("Invalid username or password"); } user.Password = ComputeHash(user.Password); await context.Users.AddAsync(user); context.SaveChanges(); }
public void TogglePaid(int id) { using (var context = new BPContext()) { var perf = context.Performances.FirstOrDefault(g => g.ID == id); if (perf != null) { perf.Paid = !perf.Paid; context.SaveChanges(); } else { throw new System.Exception("Could not find performance"); } } }
public PaymentViewModel() { using (var context = new BPContext()) { var accounts = context.Matches .AsNoTracking() .Include(g => g.Oposition) .Include(g => g.Performances).ThenInclude(g => g.Player) .ToList(); Matches = accounts; Players = context.Players.AsNoTracking() .OrderBy(g => g.FirstName) .ToArray(); } }
async Task <IActionResult> ReceiveAsync() { BPContext context = new BPContext() { HttpRequest = Request }; using (StreamReader reader = new StreamReader(context.HttpRequest.Body, Encoding.ASCII)) { context.RequestBody = reader.ReadToEnd(); } //Fire and forget verification task await Task.Run(() => VerifyTask(context, false)); return(Ok()); }
public async Task <IActionResult> Register(User user) { using (var context = new BPContext()) { if (!ModelState.IsValid) { return(View()); } else if (context.Users.Any(g => g.Username == user.Username)) { ModelState.AddModelError("", "Username already exists"); return(View()); } else { await UserAuthentication.AddAsync(user, context); return(View("Login")); } } }
public PlayersController(BPContext context) { _context = context; }
public HomeController(BPContext context) { _context = context; }
public static User GetUser(string username, string password, BPContext context) { return(context.Users.FirstOrDefault(g => g.Username == username && g.Password == ComputeHash(password))); }
public static extern void BP_Init2Default(ref BPContext bp_context);
public static extern IntPtr BP_PackConnect(ref BPContext bp_context, IntPtr name, IntPtr password);
public static extern IntPtr BP_PackPing(ref BPContext bp_context);
public TeamsController(BPContext context) { _context = context; }
public static extern IntPtr BP_PackDisconn(ref BPContext bp_context);
public PerformancesController(BPContext context) { _context = context; }
public ScoringsController(BPContext context) { _context = context; }
public async Task <IActionResult> Login(LoginModel model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Invalid username/password"); return(View()); } var user = new User("", "", model.Username, model.Password); using (var context = new BPContext()) { if (UserAuthentication.IsValidUser(user, context)) { var temp = UserAuthentication.GetUser(user.Username, user.Password, context); var claims = new List <Claim> { new Claim(ClaimTypes.Name, temp.FirstName), new Claim("FullName", temp.ToString()), new Claim(ClaimTypes.Role, temp.Access.ToString()), }; var claimsIdentity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { //AllowRefresh = <bool>, // Refreshing the authentication session should be allowed. //ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(10), // The time at which the authentication ticket expires. A // value set here overrides the ExpireTimeSpan option of // CookieAuthenticationOptions set with AddCookie. //IsPersistent = true, // Whether the authentication session is persisted across // multiple requests. Required when setting the // ExpireTimeSpan option of CookieAuthenticationOptions // set with AddCookie. Also required when setting // ExpiresUtc. //IssuedUtc = <DateTimeOffset>, // The time at which the authentication ticket was issued. //RedirectUri = <string> // The full path or absolute URI to be used as an http // redirect response value. }; await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); if (model.ReturnURL != null && Url.IsLocalUrl(model.ReturnURL)) { return(Redirect(model.ReturnURL)); } return(RedirectToAction("GetPlayerRankings", "Performances")); } else { return(View("Login")); } } }
public DataBase(BPContext db) { _db = db; }