/// <summary> /// </summary> /// <param name="operation"></param> /// <param name="schemaRegistry"></param> /// <param name="apiDescription"></param> public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription) { var scopes = apiDescription.ActionDescriptor.GetFilterPipeline() .Select(filterInfo => filterInfo.Instance) .OfType<AuthorizeAttribute>(); var allTheSameDbContext = new AllTheSameDbContext(); IPermissionService permService = new PermissionService(new UnitOfWork(allTheSameDbContext), new PermissionRepository(allTheSameDbContext)); if (operation.parameters == null) operation.parameters = new List<Parameter>(); var authorizeAttributes = scopes as IList<AuthorizeAttribute> ?? scopes.ToList(); if (!authorizeAttributes.Any()) return; var parameter = new Parameter { description = "Authorization token. Used for applying content access restrictions. Use one of the OAuth2 grants to auto-populate this value.", @in = "header", name = "Authorization", required = true, type = "string" }; operation.parameters.Add(parameter); var orgParam = new Parameter { description = "Organization ID context for this request", @in = "header", name = "orgId", required = true, type = "int" }; operation.parameters.Add(orgParam); foreach (var scope in authorizeAttributes) { if (string.IsNullOrWhiteSpace(scope.Roles)) continue; var sb = new StringBuilder("Required Permission: "); var roles = scope.Roles.Contains(',') ? scope.Roles.Split(',').ToList() : new List<string> {scope.Roles}; for (var index = 0; index < roles.Count; index++) { var role = roles[index]; var perm = permService.GetSingle(p => p.Code == role); if (perm != null) { sb.AppendFormat("({0}) {1}", perm.Code, perm.Label); } else { sb.AppendLine(role); } if (index != roles.Count - 1) { sb.Append(","); } } operation.description = sb.ToString(); } }
private void Init() { Context = new AllTheSameDbContext(); var uow = new UnitOfWork(Context); var respository = new GenericRepository <Person>(Context); Service = new EntityService <Person, IGenericRepository <Person> >(uow, respository); }
/// <summary> /// Initializes a new instance of the <see cref="BaseApiController{TEntity}" /> class. /// </summary> protected BaseApiController() { if (Context == null) { Context = new AllTheSameDbContext(); } GetServiceReference(Context); }
/// <summary> /// Initializes a new instance of the BaseApiController TEntity. /// </summary> protected BaseODataController() { if (_context == null) { _context = new AllTheSameDbContext(); } GetServiceRefernce(_context); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public RegistrationApiController() { _context = new AllTheSameDbContext(); _vendorCredentialService = new VendorCredentialService(new UnitOfWork(_context), new VendorCredentialRepository(_context)); _industryService = new IndustryService(new UnitOfWork(_context), new IndustryRepository(_context)); _organizationService = new OrganizationService(new UnitOfWork(_context), new OrganizationRepository(_context)); _orgTypeService = new OrgTypeService(new UnitOfWork(_context), new OrgTypeRepository(_context)); _vendorService = new VendorService(new UnitOfWork(_context), new VendorRepository(_context)); _vendorTypeService = new VendorTypeService(new UnitOfWork(_context), new VendorTypeRepository(_context)); _vendorAdminService = new VendorAdminService(new UnitOfWork(_context), new VendorAdminRepository(_context)); _vendorWorkerService = new VendorWorkerService(new UnitOfWork(_context), new VendorWorkerRepository(_context)); _vendorCredDocumentService = new VendorCredDocumentService(new UnitOfWork(_context), new VendorCredDocumentRepository(_context)); _addressService = new AddressService(new UnitOfWork(_context), new AddressRepository(_context)); //var vendorCredentialList = _context.VendorCredentials; //var industryList = _context.Industries; //var organizationList = _context.Organizations; //var orgTypeList = _context.OrgTypes; //var vendorList = _context.Vendors; //var vendorTypeList = _context.VendorTypes; //var vendorAdminList = _context.VendorAdmins; //var vendorWorkerList = _context.VendorWorkers; //var vendorCredDocumentList = _context.VendorCredDocuments; //var addressList = _context.Addresses; //var c = Repository<Person>.Instance.Count; //var c2 = Repository<Person>.Instance.Count; //var s = new ServiceProxy<Person,IPersonRepository>().Count; }
/// <summary> /// Initializes a new instance of the <see cref="SearchRepository{TEntity}" /> class. /// </summary> public SearchRepository() { Context = new AllTheSameDbContext(); DbSet = Context.Set <TEntity>(); }
/// <summary> /// Initializes a new instance of the <see cref="PersonController" /> class. /// </summary> public PersonMvcController() { _context = new AllTheSameDbContext(); _service = new PersonService(new UnitOfWork(_context), new PersonRepository(_context)); }
/// <summary> /// Initializes a new instance of the <see cref="AccountController" /> class. /// </summary> /// <param name="context">The context.</param> public AccountController(AllTheSameDbContext context) : base(context) { }
/// <summary> /// Initializes a new instance of the class. /// </summary> public AddressProxyController() { _context = new AllTheSameDbContext(); _serviceProxy = ServiceProxy.GetServiceRefernce <Address, IAddressRepository>(new AddressRepository(_context)); }
/// <summary> /// Initializes a new instance of the <see cref="VendorController" /> class. /// </summary> public VendorMvcController() { _context = new AllTheSameDbContext(); _service = new VendorService(new UnitOfWork(_context), new VendorRepository(_context)); }