public UserController() { TaxiHeavenContext ctx = new TaxiHeavenContext(); _userRepository = new UserRepository(ctx); _userRoleRepository = new UserRoleRepository(ctx); }
public override void OnAuthorization(HttpActionContext actionContext) { var ctx = new TaxiHeavenContext(); AuthenticationHeaderValue auth = actionContext.Request.Headers.Authorization; if (string.Compare(auth.Scheme, "Basic", StringComparison.OrdinalIgnoreCase) == 0) { string credentials = UTF8Encoding.UTF8.GetString(Convert.FromBase64String(auth.Parameter)); int separatorIndex = credentials.IndexOf(':'); if (separatorIndex >= 0) { string userName = credentials.Substring(0, separatorIndex); string password = credentials.Substring(separatorIndex + 1); var user = ctx.User.FirstOrDefault(x => x.Email == userName && x.Password == password); if (user != null) { var roles = user.UserRole.Select(x => x.RoleId).ToList(); if (_requiredRoles.Except(roles).Count() != 0) { actionContext.RequestContext.RouteData.Values["Authorized"] = false; return; } actionContext.RequestContext.RouteData.Values["Authorized"] = true; } else { actionContext.RequestContext.RouteData.Values["Authorized"] = false; } } } }
public OrderController() { TaxiHeavenContext ctx = new TaxiHeavenContext(); _driverRepository = new DriverRepository(ctx); _workSessionRepository = new WorkSessionRepository(ctx); _orderRepository = new OrderRepository(ctx); }
public UserRepository(TaxiHeavenContext ctx) : base(ctx) { }
public BasementController() { TaxiHeavenContext ctx = new TaxiHeavenContext(); _basementRepository = new BasementRepository(ctx); }
public WorkSessionRepository(TaxiHeavenContext ctx) : base(ctx) { }
public BasementRepository(TaxiHeavenContext ctx) : base(ctx) { }
public DeviceRepository(TaxiHeavenContext ctx) : base(ctx) { }
protected Repository(TaxiHeavenContext context) { _context = context; }
protected Repository() { _context = new TaxiHeavenContext(); }