public UserDetails(string username) { MetallicaContext db = new MetallicaContext(); this.UserId = (from n in db.Users where n.UserName == username select n.Id).FirstOrDefault(); this.Name = (from n in db.Users where n.UserName == username select n.FirstName + " " + n.LastName).FirstOrDefault().ToString(); }
public RefData() { MetallicaContext db = new MetallicaContext(); this.Commodities = (from n in db.Commodities select n).ToList(); this.CounterParties = (from n in db.CounterParties select n).ToList(); this.Locations = (from n in db.Locations select n).ToList(); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var identity = new ClaimsIdentity(context.Options.AuthenticationType); context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); try { using (var db = new MetallicaContext()) { if (db != null) { //var empl = db.Employees.ToList(); var user = db.Users.ToList(); if (user != null) { if (!string.IsNullOrEmpty(user.Where(u => u.UserName == context.UserName && u.Password == context.Password).FirstOrDefault().UserName)) { identity.AddClaim(new Claim("Age", "16")); var props = new AuthenticationProperties(new Dictionary <string, string> { { "userdisplayname", context.UserName }, { "role", "admin" } }); var ticket = new AuthenticationTicket(identity, props); context.Validated(ticket); } else { context.SetError("invalid_grant", "Provided username and password is incorrect"); context.Rejected(); } } } else { context.SetError("invalid_grant", "Provided username and password is incorrect"); context.Rejected(); } return; } } catch (System.Exception) { context.SetError("invalid_grant", "Provided username and password is incorrect"); context.Rejected(); return; } }
public FilterLayer(FilterCriteria filterCriteria) { trades = new List <Trade>(); db = new MetallicaContext(); this.filterCriteria = filterCriteria; }
public BusinessLayer() { tradeQueue = new TradeMQueue(); tickerQueue = new TickerMQueue(); context = new MetallicaContext(); }