├── .gitattributes
├── .gitignore
├── README.md
├── angular
└── modals
│ ├── .angular-cli.json
│ ├── .editorconfig
│ ├── .gitignore
│ ├── .vscode
│ └── settings.json
│ ├── README.md
│ ├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ └── tsconfig.e2e.json
│ ├── karma.conf.js
│ ├── package-lock.json
│ ├── package.json
│ ├── protractor.conf.js
│ ├── src
│ ├── app
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ └── app.module.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
│ ├── tsconfig.json
│ └── tslint.json
├── angularjs
└── porcentaje
│ ├── .gitignore
│ ├── app.js
│ ├── bower.json
│ ├── package.json
│ └── public
│ ├── index.html
│ ├── js
│ └── app
│ │ └── index.js
│ └── templates
│ ├── nuevo-activo.html
│ └── nuevo-heredero.html
├── dotNet
├── FirmaElectronica
│ ├── FirmaElectronica.Tests
│ │ ├── FirmaElectronica.Tests.csproj
│ │ ├── FirmanteTests.cs
│ │ ├── Herramientas.cs
│ │ ├── NotarioTests.cs
│ │ ├── Recursos
│ │ │ ├── certificado.pfx
│ │ │ ├── documento-firmado.pdf
│ │ │ └── documento.pdf
│ │ └── packages.config
│ ├── FirmaElectronica.sln
│ └── FirmaElectronica
│ │ ├── Certificado.cs
│ │ ├── FirmaElectronica.csproj
│ │ ├── Firmante.cs
│ │ ├── Notario.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ └── packages.config
├── MaestroDetalleMVC4-01
│ ├── MaestroDetalleMVC01.sln
│ └── MvcApplication
│ │ ├── App_Start
│ │ ├── FilterConfig.cs
│ │ └── RouteConfig.cs
│ │ ├── Controllers
│ │ └── FacturasController.cs
│ │ ├── Entidades
│ │ ├── Detalle.cs
│ │ ├── Factura.cs
│ │ └── Producto.cs
│ │ ├── Global.asax
│ │ ├── Global.asax.cs
│ │ ├── MvcApplication.csproj
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── Views
│ │ ├── Facturas
│ │ │ ├── Create.cshtml
│ │ │ └── Index.cshtml
│ │ ├── Shared
│ │ │ └── _Layout.cshtml
│ │ ├── Web.config
│ │ └── _ViewStart.cshtml
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ ├── Web.config
│ │ └── packages.config
├── MaestroDetalleMVC4-02
│ ├── MaestroDetalleMVC02.sln
│ └── MvcApplication
│ │ ├── App_Start
│ │ ├── FilterConfig.cs
│ │ └── RouteConfig.cs
│ │ ├── Controllers
│ │ └── FacturasController.cs
│ │ ├── Entidades
│ │ ├── Detalle.cs
│ │ ├── Factura.cs
│ │ └── Producto.cs
│ │ ├── Extensions
│ │ └── MvcHtmlStringExtensions.cs
│ │ ├── Global.asax
│ │ ├── Global.asax.cs
│ │ ├── MvcApplication.csproj
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── Scripts
│ │ ├── ViewModels
│ │ │ └── FacturaCreateViewModel.js
│ │ ├── _references.js
│ │ ├── jquery-2.0.0-vsdoc.js
│ │ ├── jquery-2.0.0.js
│ │ ├── jquery-2.0.0.min.js
│ │ ├── jquery-2.0.0.min.map
│ │ ├── jquery.validate-vsdoc.js
│ │ ├── jquery.validate.js
│ │ ├── jquery.validate.min.js
│ │ ├── jquery.validate.unobtrusive.js
│ │ ├── jquery.validate.unobtrusive.min.js
│ │ ├── knockout-2.2.1.debug.js
│ │ ├── knockout-2.2.1.js
│ │ ├── knockout.validation.debug.js
│ │ └── knockout.validation.js
│ │ ├── Views
│ │ ├── Facturas
│ │ │ ├── Create.cshtml
│ │ │ └── Index.cshtml
│ │ ├── Shared
│ │ │ └── _Layout.cshtml
│ │ ├── Web.config
│ │ └── _ViewStart.cshtml
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ ├── Web.config
│ │ └── packages.config
├── ManejoDeCache
│ ├── .nuget
│ │ ├── NuGet.Config
│ │ ├── NuGet.exe
│ │ └── NuGet.targets
│ ├── ManejoDeCache.sln
│ ├── MvcApp
│ │ ├── App_Start
│ │ │ ├── FilterConfig.cs
│ │ │ ├── RouteConfig.cs
│ │ │ └── WebApiConfig.cs
│ │ ├── Controllers
│ │ │ └── HomeController.cs
│ │ ├── Global.asax
│ │ ├── Global.asax.cs
│ │ ├── Models
│ │ │ └── Empresa.cs
│ │ ├── MvcApp.csproj
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ ├── Servicios
│ │ │ └── EmpresaServicio.cs
│ │ ├── Views
│ │ │ ├── Home
│ │ │ │ └── Index.cshtml
│ │ │ └── Web.config
│ │ ├── Web References
│ │ │ └── ServicioWebEmpresas
│ │ │ │ ├── Empresa.datasource
│ │ │ │ ├── Reference.cs
│ │ │ │ ├── Reference.map
│ │ │ │ ├── ServicioWebEmpresas.disco
│ │ │ │ └── ServicioWebEmpresas.wsdl
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ ├── Web.config
│ │ └── packages.config
│ ├── README.md
│ └── WebServices
│ │ ├── Entidades
│ │ └── Empresa.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── ServiciosWeb
│ │ ├── ServicioWebEmpresas.asmx
│ │ └── ServicioWebEmpresas.asmx.cs
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ ├── Web.config
│ │ └── WebServices.csproj
├── MultipleFilesUpload
│ ├── MultipleFilesUpload.sln
│ ├── MvcDemo-01
│ │ ├── App_Start
│ │ │ └── RouteConfig.cs
│ │ ├── Content
│ │ │ └── main.css
│ │ ├── Controllers
│ │ │ └── HomeController.cs
│ │ ├── Global.asax
│ │ ├── Global.asax.cs
│ │ ├── Models
│ │ │ └── CargarArchivoModel.cs
│ │ ├── MvcDemo-01.csproj
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Scripts
│ │ │ ├── jquery-2.1.1.intellisense.js
│ │ │ ├── jquery-2.1.1.js
│ │ │ ├── jquery-2.1.1.min.js
│ │ │ ├── jquery-2.1.1.min.map
│ │ │ └── main.js
│ │ ├── Views
│ │ │ ├── Home
│ │ │ │ └── Index.cshtml
│ │ │ └── web.config
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ ├── Web.config
│ │ └── packages.config
│ └── README.md
├── dotnetcore-cache-sample
│ ├── .vscode
│ │ ├── launch.json
│ │ └── tasks.json
│ ├── Controllers
│ │ ├── BooksAsyncController.cs
│ │ └── BooksController.cs
│ ├── Entities
│ │ └── Book.cs
│ ├── Models
│ │ └── CreateOrUpdateBookModel.cs
│ ├── Program.cs
│ ├── Repositories
│ │ ├── BooksCachedAsyncRepository.cs
│ │ ├── BooksCachedRepository.cs
│ │ ├── DbSchema.cs
│ │ ├── IBooksAsyncRepository.cs
│ │ ├── IBooksRepository.cs
│ │ ├── IConnectionAsyncProvider.cs
│ │ ├── IConnectionProvider.cs
│ │ ├── SqliteBooksAsyncRepository.cs
│ │ ├── SqliteBooksRepository.cs
│ │ ├── SqliteConnectionProvider.cs
│ │ └── SqliteOptions.cs
│ ├── Resources
│ │ └── database-schema.sql
│ ├── Startup.cs
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ └── dotnetcore-cache-sample.csproj
└── oauth-ng-cs
│ ├── api
│ ├── Controllers
│ │ ├── PingController.cs
│ │ └── ProductosController.cs
│ ├── Entidades
│ │ ├── Factura.cs
│ │ ├── FacturaDetalle.cs
│ │ └── Producto.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Repositorios
│ │ ├── BaseDeDatos.cs
│ │ └── ProductosRepositorio.cs
│ ├── Servicios
│ │ └── ProductoServicio.cs
│ ├── Startup.cs
│ ├── UserExtensions.cs
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Web.config
│ ├── api.csproj
│ └── packages.config
│ ├── app
│ ├── Content
│ │ ├── bootstrap-theme.css
│ │ ├── bootstrap-theme.css.map
│ │ ├── bootstrap-theme.min.css
│ │ ├── bootstrap-theme.min.css.map
│ │ ├── bootstrap.css
│ │ ├── bootstrap.css.map
│ │ ├── bootstrap.min.css
│ │ ├── bootstrap.min.css.map
│ │ ├── custom.css
│ │ ├── custom.min.css
│ │ ├── font-awesome.css
│ │ ├── font-awesome.min.css
│ │ ├── jasmine
│ │ │ ├── jasmine.css
│ │ │ └── jasmine_favicon.png
│ │ └── ui-bootstrap-csp.css
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Scripts
│ │ ├── _references.js
│ │ ├── angular-mocks.js
│ │ ├── angular-ui-router.js
│ │ ├── angular-ui-router.min.js
│ │ ├── angular-ui
│ │ │ ├── ui-bootstrap-tpls.js
│ │ │ ├── ui-bootstrap-tpls.min.js
│ │ │ ├── ui-bootstrap.js
│ │ │ └── ui-bootstrap.min.js
│ │ ├── angular.js
│ │ ├── angular.min.js
│ │ ├── angular.min.js.map
│ │ ├── bootstrap.js
│ │ ├── bootstrap.min.js
│ │ ├── jasmine
│ │ │ ├── boot.js
│ │ │ ├── console.js
│ │ │ ├── jasmine-html.js
│ │ │ └── jasmine.js
│ │ ├── jquery-3.1.0.intellisense.js
│ │ ├── jquery-3.1.0.js
│ │ ├── jquery-3.1.0.min.js
│ │ ├── jquery-3.1.0.min.map
│ │ ├── jquery-3.1.0.slim.js
│ │ ├── jquery-3.1.0.slim.min.js
│ │ ├── jquery-3.1.0.slim.min.map
│ │ ├── oidc-client.js
│ │ └── oidc-client.min.js
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Web.config
│ ├── app.csproj
│ ├── app
│ │ ├── app.js
│ │ ├── auth.js
│ │ ├── boot.js
│ │ ├── core
│ │ │ ├── layout.controller.js
│ │ │ ├── layout.template.html
│ │ │ ├── profile.directive.js
│ │ │ ├── profile.template.html
│ │ │ ├── sidebar-footer.directive.js
│ │ │ ├── sidebar-footer.template.html
│ │ │ ├── sidebar-menu.controller.js
│ │ │ ├── sidebar-menu.directive.js
│ │ │ ├── sidebar-menu.service.js
│ │ │ ├── sidebar-menu.specs.js
│ │ │ ├── sidebar-menu.template.html
│ │ │ ├── sidebar.directive.js
│ │ │ ├── sidebar.template.html
│ │ │ ├── top-nav.directive.js
│ │ │ └── top-nav.template.html
│ │ ├── home
│ │ │ ├── dashboard-graph.directive.js
│ │ │ ├── dashboard-graph.template.html
│ │ │ ├── dashboard.template.html
│ │ │ ├── ping.directive.js
│ │ │ ├── top-tiles.directive.js
│ │ │ └── top-tiles.template.html
│ │ ├── mantenimientos
│ │ │ ├── productos-crear.controller.js
│ │ │ ├── productos-crear.template.html
│ │ │ ├── productos-listado.controller.js
│ │ │ ├── productos-listado.template.html
│ │ │ └── productos.servicio.js
│ │ └── routes.js
│ ├── check_session.html
│ ├── favicon.ico
│ ├── fonts
│ │ ├── FontAwesome.otf
│ │ ├── fontawesome-webfont.eot
│ │ ├── fontawesome-webfont.svg
│ │ ├── fontawesome-webfont.ttf
│ │ ├── fontawesome-webfont.woff
│ │ ├── fontawesome-webfont.woff2
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.svg
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ ├── images
│ │ └── img.jpg
│ ├── index.html
│ ├── packages.config
│ ├── signedout.html
│ ├── signin-renew.html
│ ├── signin.html
│ ├── specs.html
│ └── specs.js
│ ├── auth
│ ├── App_Data
│ │ └── idsrv3test.pfx
│ ├── Configuration
│ │ ├── Certificate.cs
│ │ ├── Clients.cs
│ │ ├── Scopes.cs
│ │ └── Users.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Startup.cs
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Web.config
│ ├── auth.csproj
│ ├── favicon.ico
│ └── packages.config
│ └── oauth-ng-cs.sln
└── html
└── yahoostyleheader.html
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Ejemplos
2 | ========
3 |
4 | Proyectos o fragmentos de código que por alguna razón u otra no los coloco como [gists][1] y que pueden servir para ejemplificar algunos conceptos.
5 |
6 | [1]: https://gist.github.com/ "GitHub Gist"
7 |
--------------------------------------------------------------------------------
/angular/modals/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "modals"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json",
40 | "exclude": "**/node_modules/**"
41 | },
42 | {
43 | "project": "src/tsconfig.spec.json",
44 | "exclude": "**/node_modules/**"
45 | },
46 | {
47 | "project": "e2e/tsconfig.e2e.json",
48 | "exclude": "**/node_modules/**"
49 | }
50 | ],
51 | "test": {
52 | "karma": {
53 | "config": "./karma.conf.js"
54 | }
55 | },
56 | "defaults": {
57 | "styleExt": "css",
58 | "component": {}
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/angular/modals/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/angular/modals/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | testem.log
34 | /typings
35 | yarn-error.log
36 |
37 | # e2e
38 | /e2e/*.js
39 | /e2e/*.map
40 |
41 | # System Files
42 | .DS_Store
43 | Thumbs.db
44 |
--------------------------------------------------------------------------------
/angular/modals/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "eslint.enable": false
3 | }
--------------------------------------------------------------------------------
/angular/modals/README.md:
--------------------------------------------------------------------------------
1 | # Modals
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.3.0.
4 |
5 | ## Development server
6 |
7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8 |
9 | ## Code scaffolding
10 |
11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12 |
13 | ## Build
14 |
15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 | Before running the tests make sure you are serving the app via `ng serve`.
25 |
26 | ## Further help
27 |
28 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
29 |
--------------------------------------------------------------------------------
/angular/modals/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('modals App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to app!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/angular/modals/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/angular/modals/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "jasminewd2",
11 | "node"
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/angular/modals/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 | angularCli: {
23 | environment: 'dev'
24 | },
25 | reporters: ['progress', 'kjhtml'],
26 | port: 9876,
27 | colors: true,
28 | logLevel: config.LOG_INFO,
29 | autoWatch: true,
30 | browsers: ['Chrome'],
31 | singleRun: false
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/angular/modals/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "modals",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/animations": "^4.2.4",
16 | "@angular/common": "^4.2.4",
17 | "@angular/compiler": "^4.2.4",
18 | "@angular/core": "^4.2.4",
19 | "@angular/forms": "^4.2.4",
20 | "@angular/http": "^4.2.4",
21 | "@angular/platform-browser": "^4.2.4",
22 | "@angular/platform-browser-dynamic": "^4.2.4",
23 | "@angular/router": "^4.2.4",
24 | "core-js": "^2.4.1",
25 | "rxjs": "^5.4.2",
26 | "zone.js": "^0.8.14"
27 | },
28 | "devDependencies": {
29 | "@angular/cli": "1.3.0",
30 | "@angular/compiler-cli": "^4.2.4",
31 | "@angular/language-service": "^4.2.4",
32 | "@types/jasmine": "~2.5.53",
33 | "@types/jasminewd2": "~2.0.2",
34 | "@types/node": "~6.0.60",
35 | "codelyzer": "~3.1.1",
36 | "jasmine-core": "~2.6.2",
37 | "jasmine-spec-reporter": "~4.1.0",
38 | "karma": "~1.7.0",
39 | "karma-chrome-launcher": "~2.1.1",
40 | "karma-cli": "~1.0.1",
41 | "karma-coverage-istanbul-reporter": "^1.2.1",
42 | "karma-jasmine": "~1.1.0",
43 | "karma-jasmine-html-reporter": "^0.2.2",
44 | "protractor": "~5.1.2",
45 | "ts-node": "~3.2.0",
46 | "tslint": "~5.3.2",
47 | "typescript": "~2.3.3"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/angular/modals/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/angular/modals/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/angular/modals/src/app/app.component.css
--------------------------------------------------------------------------------
/angular/modals/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Welcome to {{title}}!
5 |
6 |

7 |
8 | Here are some links to help you start:
9 |
10 | -
11 |
12 |
13 | -
14 |
15 |
16 | -
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/angular/modals/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/angular/modals/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'app';
10 | }
11 |
--------------------------------------------------------------------------------
/angular/modals/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 |
6 | @NgModule({
7 | declarations: [
8 | AppComponent
9 | ],
10 | imports: [
11 | BrowserModule
12 | ],
13 | providers: [],
14 | bootstrap: [AppComponent]
15 | })
16 | export class AppModule { }
17 |
--------------------------------------------------------------------------------
/angular/modals/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/angular/modals/src/assets/.gitkeep
--------------------------------------------------------------------------------
/angular/modals/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/angular/modals/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/angular/modals/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/angular/modals/src/favicon.ico
--------------------------------------------------------------------------------
/angular/modals/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Modals
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/angular/modals/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/angular/modals/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/angular/modals/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare const __karma__: any;
17 | declare const require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/angular/modals/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "baseUrl": "./",
6 | "module": "es2015",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/angular/modals/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/angular/modals/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/angular/modals/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "sourceMap": true,
6 | "declaration": false,
7 | "moduleResolution": "node",
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "target": "es5",
11 | "typeRoots": [
12 | "node_modules/@types"
13 | ],
14 | "lib": [
15 | "es2017",
16 | "dom"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/angularjs/porcentaje/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /bower_components
--------------------------------------------------------------------------------
/angularjs/porcentaje/app.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var app = express();
3 |
4 | app.use(express.static('public'));
5 |
6 | app.use('/js/libs', express.static('bower_components/angular'));
7 | app.use('/js/libs', express.static('bower_components/angular-animate'));
8 | app.use('/js/libs', express.static('bower_components/angular-touch'));
9 | app.use('/js/libs', express.static('bower_components/angular-ui-bootstrap-bower'));
10 | app.use('/js/libs', express.static('bower_components/underscore'));
11 |
12 | app.use('/css', express.static('bower_components/angular-ui-bootstrap-bower'));
13 | app.use('/css', express.static('bower_components/bootstrap/dist/css'));
14 |
15 | app.use('/fonts', express.static('bower_components/bootstrap/dist/fonts'));
16 |
17 | var server = app.listen(3000, function () {
18 |
19 | var host = server.address().address;
20 | var port = server.address().port;
21 |
22 | console.log('Example app listening at http://%s:%s', host, port);
23 |
24 | });
--------------------------------------------------------------------------------
/angularjs/porcentaje/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo-porcentaje",
3 | "version": "0.0.0",
4 | "authors": [
5 | "Miguel Román "
6 | ],
7 | "license": "MIT",
8 | "ignore": [
9 | "**/.*",
10 | "node_modules",
11 | "bower_components",
12 | "test",
13 | "tests"
14 | ],
15 | "dependencies": {
16 | "angular": "1.3.13",
17 | "angular-animate": "1.3.13",
18 | "angular-touch": "1.3.13",
19 | "angular-ui-bootstrap-bower": "0.13.0",
20 | "bootstrap": "3.1.1",
21 | "underscore": "~1.8.3"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/angularjs/porcentaje/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo-porcentaje",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "Miguel Roman",
10 | "license": "ISC",
11 | "dependencies": {
12 | "express": "^4.12.4"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/angularjs/porcentaje/public/templates/nuevo-activo.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/angularjs/porcentaje/public/templates/nuevo-heredero.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica.Tests/FirmanteTests.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using System.IO;
3 |
4 | namespace FirmaElectronica.Tests
5 | {
6 | [TestFixture()]
7 | public class FirmanteTests
8 | {
9 | [Test()]
10 | public void Firmar_FirmaCorrectaDelDocumento()
11 | {
12 | var recursos = Herramientas.GetResourcesPath();
13 | var pathCertificado = Path.Combine(recursos, "certificado.pfx");
14 | var pathDocumentoSinFirma = Path.Combine(recursos, "documento.pdf");
15 | var pathDocumentoConFirma = Path.Combine(recursos, "documento-con-firma-test.pdf");
16 | var certificado = new Certificado(pathCertificado);
17 | var firmante = new Firmante(certificado);
18 |
19 | firmante.Firmar(pathDocumentoSinFirma, pathDocumentoConFirma);
20 |
21 | Assert.IsTrue(File.Exists(pathDocumentoConFirma));
22 | }
23 |
24 |
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica.Tests/Herramientas.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FirmaElectronica.Tests
4 | {
5 | internal static class Herramientas
6 | {
7 | internal static string GetResourcesPath()
8 | {
9 | return System.IO.Path.Combine (GetAssemblyDirectory (), "Recursos");
10 | }
11 |
12 | internal static string GetAssemblyDirectory()
13 | {
14 | string codeBase = System.Reflection.Assembly.GetExecutingAssembly ().CodeBase;
15 | UriBuilder uri = new UriBuilder (codeBase);
16 | string path = Uri.UnescapeDataString (uri.Path);
17 | return System.IO.Path.GetDirectoryName (path);
18 | }
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica.Tests/NotarioTests.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using System.IO;
3 |
4 | namespace FirmaElectronica.Tests
5 | {
6 | [TestFixture()]
7 | public class NotarioTests
8 | {
9 | [Test()]
10 | public void CertificarDocumento_CertificaDocumentosFirmados()
11 | {
12 | var recursos = Herramientas.GetResourcesPath();
13 | var pathCertificado = Path.Combine(recursos, "certificado.pfx");
14 | var pathDocumento = Path.Combine(recursos, "documento-firmado.pdf");
15 | var certificado = new Certificado(pathCertificado);
16 | var notario = new Notario(certificado);
17 |
18 | var resultado = notario.CertificarDocumento(pathDocumento);
19 |
20 | Assert.IsTrue(resultado);
21 | }
22 |
23 | [Test()]
24 | public void CertificarDocumento_NoCertificaDocumentosSinFirma()
25 | {
26 | var recursos = Herramientas.GetResourcesPath();
27 | var pathCertificado = Path.Combine(recursos, "certificado.pfx");
28 | var pathDocumento = Path.Combine(recursos, "documento.pdf");
29 | var certificado = new Certificado(pathCertificado);
30 | var notario = new Notario(certificado);
31 |
32 | var resultado = notario.CertificarDocumento(pathDocumento);
33 |
34 | Assert.IsFalse(resultado);
35 | }
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica.Tests/Recursos/certificado.pfx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/FirmaElectronica/FirmaElectronica.Tests/Recursos/certificado.pfx
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica.Tests/Recursos/documento-firmado.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/FirmaElectronica/FirmaElectronica.Tests/Recursos/documento-firmado.pdf
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica.Tests/Recursos/documento.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/FirmaElectronica/FirmaElectronica.Tests/Recursos/documento.pdf
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirmaElectronica.Tests", "FirmaElectronica.Tests\FirmaElectronica.Tests.csproj", "{0FA03D22-9707-494D-927F-8D04A7C128F0}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirmaElectronica", "FirmaElectronica\FirmaElectronica.csproj", "{F469EBCB-7822-477E-8266-8B2979EDF91E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {0FA03D22-9707-494D-927F-8D04A7C128F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {0FA03D22-9707-494D-927F-8D04A7C128F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {0FA03D22-9707-494D-927F-8D04A7C128F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {0FA03D22-9707-494D-927F-8D04A7C128F0}.Release|Any CPU.Build.0 = Release|Any CPU
18 | {F469EBCB-7822-477E-8266-8B2979EDF91E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {F469EBCB-7822-477E-8266-8B2979EDF91E}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {F469EBCB-7822-477E-8266-8B2979EDF91E}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {F469EBCB-7822-477E-8266-8B2979EDF91E}.Release|Any CPU.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | EndGlobal
24 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica/Certificado.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Linq;
3 | using Org.BouncyCastle.Crypto;
4 | using Org.BouncyCastle.Pkcs;
5 | using Org.BouncyCastle.X509;
6 |
7 | namespace FirmaElectronica
8 | {
9 | public class Certificado
10 | {
11 | public AsymmetricKeyParameter Key { get; private set; }
12 |
13 | public X509Certificate[] Chain { get; private set; }
14 |
15 | public Certificado(string rutaCompletaDelPfx, string claveDelPfx = null)
16 | {
17 | using (var file = File.OpenRead(rutaCompletaDelPfx))
18 | {
19 | var password = claveDelPfx?.ToCharArray() ?? new char[] { /* password en blanco */ };
20 | var store = new Pkcs12Store(file, password);
21 | var alias = GetCertificateAlias(store);
22 |
23 | Key = store.GetKey(alias).Key;
24 | Chain = store.GetCertificateChain(alias).Select(x => x.Certificate).ToArray();
25 | }
26 | }
27 |
28 | private static string GetCertificateAlias(Pkcs12Store store)
29 | {
30 | foreach (string currentAlias in store.Aliases)
31 | {
32 | if (store.IsKeyEntry(currentAlias))
33 | {
34 | return currentAlias;
35 | }
36 | }
37 |
38 | return null;
39 | }
40 | }
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica/FirmaElectronica.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {F469EBCB-7822-477E-8266-8B2979EDF91E}
7 | Library
8 | FirmaElectronica
9 | FirmaElectronica
10 | v4.5
11 |
12 |
13 | true
14 | full
15 | false
16 | bin\Debug
17 | DEBUG;
18 | prompt
19 | 4
20 | false
21 |
22 |
23 | full
24 | true
25 | bin\Release
26 | prompt
27 | 4
28 | false
29 |
30 |
31 |
32 |
33 | ..\packages\iTextSharp.5.5.9\lib\itextsharp.dll
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica/Firmante.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using iTextSharp.text.pdf;
3 | using iTextSharp.text.pdf.security;
4 |
5 | namespace FirmaElectronica
6 | {
7 | public class Firmante
8 | {
9 | private readonly Certificado certificado;
10 |
11 | public Firmante(Certificado certificado)
12 | {
13 | this.certificado = certificado;
14 | }
15 |
16 | public void Firmar(string rutaDocumentoSinFirma, string rutaDocumentoFirmado)
17 | {
18 | using (var reader = new PdfReader(rutaDocumentoSinFirma))
19 | using (var writer = new FileStream(rutaDocumentoFirmado, FileMode.Create, FileAccess.Write))
20 | using (var stamper = PdfStamper.CreateSignature(reader, writer, '\0', null, true))
21 | {
22 | var signature = stamper.SignatureAppearance;
23 | signature.CertificationLevel = PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED;
24 | signature.Reason = "Firma del sistema";
25 | signature.ReasonCaption = "Tipo de firma: ";
26 |
27 | var signatureKey = new PrivateKeySignature(certificado.Key, DigestAlgorithms.SHA256);
28 | var signatureChain = certificado.Chain;
29 | var standard = CryptoStandard.CADES;
30 |
31 | MakeSignature.SignDetached(signature, signatureKey, signatureChain, null, null, null, 0, standard);
32 | }
33 | }
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica/Notario.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using iTextSharp.text.pdf;
4 | using Org.BouncyCastle.Security;
5 |
6 | namespace FirmaElectronica
7 | {
8 | public class Notario
9 | {
10 | private readonly Certificado certificado;
11 |
12 | public Notario(Certificado certificado)
13 | {
14 | this.certificado = certificado;
15 | }
16 |
17 | public bool CertificarDocumento(string rutaDocumentoFirmado)
18 | {
19 | using (var reader = new PdfReader(rutaDocumentoFirmado))
20 | {
21 | var campos = reader.AcroFields;
22 | var nombresDefirmas = campos.GetSignatureNames();
23 | foreach (var nombre in nombresDefirmas)
24 | {
25 | if (ValidarFirma(campos, nombre))
26 | {
27 | return true;
28 | }
29 | }
30 | }
31 |
32 | return false;
33 | }
34 |
35 | private bool ValidarFirma(AcroFields campos, string nombre)
36 | {
37 | // Solo se verificará la última revision del documento.
38 | if (campos.GetRevision(nombre) != campos.TotalRevisions)
39 | return false;
40 |
41 | // Solo se verificará si la firma es de todo el documento.
42 | if (!campos.SignatureCoversWholeDocument(nombre))
43 | return false;
44 |
45 | var firma = campos.VerifySignature(nombre);
46 |
47 | if (!firma.Verify())
48 | return false;
49 |
50 | foreach (var certificadoDocumento in firma.Certificates)
51 | {
52 |
53 | foreach (var certificadoDeConfianza in certificado.Chain)
54 | {
55 | try
56 | {
57 | certificadoDocumento.Verify(certificadoDeConfianza.GetPublicKey());
58 | // Si llega hasta aquí, es porque la última firma fue realizada
59 | // con el certificado del sistema.
60 | return true;
61 | }
62 | catch (InvalidKeyException)
63 | {
64 | continue;
65 | }
66 | catch (Exception ex)
67 | {
68 | Trace.TraceError("Error: {0}", ex);
69 | continue;
70 | }
71 | }
72 | }
73 |
74 | return false;
75 | }
76 | }
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle ("FirmaElectronica")]
8 | [assembly: AssemblyDescription ("")]
9 | [assembly: AssemblyConfiguration ("")]
10 | [assembly: AssemblyCompany ("")]
11 | [assembly: AssemblyProduct ("")]
12 | [assembly: AssemblyCopyright ("mike")]
13 | [assembly: AssemblyTrademark ("")]
14 | [assembly: AssemblyCulture ("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion ("1.0.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
28 |
--------------------------------------------------------------------------------
/dotNet/FirmaElectronica/FirmaElectronica/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MaestroDetalleMVC01.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcApplication", "MvcApplication\MvcApplication.csproj", "{54908330-DF09-46DE-B7F2-829D97407788}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {54908330-DF09-46DE-B7F2-829D97407788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {54908330-DF09-46DE-B7F2-829D97407788}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {54908330-DF09-46DE-B7F2-829D97407788}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {54908330-DF09-46DE-B7F2-829D97407788}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/App_Start/FilterConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 |
3 | namespace MvcApplication
4 | {
5 | public class FilterConfig
6 | {
7 | public static void RegisterGlobalFilters(GlobalFilterCollection filters)
8 | {
9 | filters.Add(new HandleErrorAttribute());
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/App_Start/RouteConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 | using System.Web.Routing;
3 |
4 | namespace MvcApplication
5 | {
6 | public class RouteConfig
7 | {
8 | public static void RegisterRoutes(RouteCollection routes)
9 | {
10 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
11 |
12 | routes.MapRoute(
13 | name: "Default",
14 | url: "{controller}/{action}/{id}",
15 | defaults: new { controller = "Facturas", action = "Index", id = UrlParameter.Optional }
16 | );
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Entidades/Detalle.cs:
--------------------------------------------------------------------------------
1 | namespace MvcApplication.Entidades
2 | {
3 | public class Detalle
4 | {
5 | public int FacturaId { get; set; }
6 |
7 | public int ProductoId { get; set; }
8 |
9 | public decimal Precio { get; set; }
10 |
11 | public decimal Cantidad { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Entidades/Factura.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace MvcApplication.Entidades
5 | {
6 | public class Factura
7 | {
8 | public int Id { get; set; }
9 |
10 | public DateTime Fecha { get; set; }
11 |
12 | public string Nit { get; set; }
13 |
14 | public string ClienteNombre { get; set; }
15 |
16 | public ICollection Detalle { get; set; }
17 |
18 | public Factura()
19 | {
20 | this.Detalle = new HashSet();
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Entidades/Producto.cs:
--------------------------------------------------------------------------------
1 | namespace MvcApplication.Entidades
2 | {
3 | public class Producto
4 | {
5 | public int Id { get; set; }
6 |
7 | public string Nombre { get; set; }
8 |
9 | public decimal Precio { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="MvcApplication.MvcApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 | using System.Web.Routing;
3 |
4 | namespace MvcApplication
5 | {
6 | // Note: For instructions on enabling IIS6 or IIS7 classic mode,
7 | // visit http://go.microsoft.com/?LinkId=9394801
8 | public class MvcApplication : System.Web.HttpApplication
9 | {
10 | protected void Application_Start()
11 | {
12 | AreaRegistration.RegisterAllAreas();
13 |
14 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
15 | RouteConfig.RegisterRoutes(RouteTable.Routes);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("MvcApplication")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("MvcApplication")]
12 | [assembly: AssemblyCopyright("Copyright © 2013")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("2fee952a-f55d-429c-b301-4b8a9c833785")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Revision and Build Numbers
32 | // by using the '*' as shown below:
33 | [assembly: AssemblyVersion("1.0.0.0")]
34 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Views/Facturas/Create.cshtml:
--------------------------------------------------------------------------------
1 | @model MvcApplication.Entidades.Factura
2 |
3 | @using (Html.BeginForm()) {
4 | @Html.AntiForgeryToken()
5 |
6 |
53 | }
54 |
55 |
56 | @Html.ActionLink("Volver al listado", "Index")
57 |
58 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Views/Facturas/Index.cshtml:
--------------------------------------------------------------------------------
1 | @model IEnumerable
2 |
3 | @{
4 | ViewBag.Title = "Index";
5 | }
6 |
7 | Listado de facturas
8 |
9 |
10 | @Html.ActionLink("Nueva Factura", "Create")
11 |
12 |
13 |
14 | |
15 | @Html.DisplayNameFor(model => model.Fecha)
16 | |
17 |
18 | @Html.DisplayNameFor(model => model.Nit)
19 | |
20 |
21 | @Html.DisplayNameFor(model => model.ClienteNombre)
22 | |
23 | |
24 |
25 |
26 | @foreach (var item in Model) {
27 |
28 | |
29 | @Html.DisplayFor(modelItem => item.Fecha)
30 | |
31 |
32 | @Html.DisplayFor(modelItem => item.Nit)
33 | |
34 |
35 | @Html.DisplayFor(modelItem => item.ClienteNombre)
36 | |
37 |
38 | @Html.ActionLink("Editar", "Edit", new { id=item.Id }) |
39 | @Html.ActionLink("Detalles", "Details", new { id=item.Id }) |
40 | @Html.ActionLink("Eliminar", "Delete", new { id=item.Id })
41 | |
42 |
43 | }
44 |
45 |
46 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Demo
7 |
8 |
9 |
10 | @RenderBody()
11 |
12 |
13 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "~/Views/Shared/_Layout.cshtml";
3 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-01/MvcApplication/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MaestroDetalleMVC02.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcApplication", "MvcApplication\MvcApplication.csproj", "{27A3F5CE-A09B-4611-84BB-D384D922B378}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {27A3F5CE-A09B-4611-84BB-D384D922B378}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {27A3F5CE-A09B-4611-84BB-D384D922B378}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {27A3F5CE-A09B-4611-84BB-D384D922B378}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {27A3F5CE-A09B-4611-84BB-D384D922B378}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/App_Start/FilterConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 |
3 | namespace MvcApplication
4 | {
5 | public class FilterConfig
6 | {
7 | public static void RegisterGlobalFilters(GlobalFilterCollection filters)
8 | {
9 | filters.Add(new HandleErrorAttribute());
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/App_Start/RouteConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 | using System.Web.Routing;
3 |
4 | namespace MvcApplication
5 | {
6 | public class RouteConfig
7 | {
8 | public static void RegisterRoutes(RouteCollection routes)
9 | {
10 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
11 |
12 | routes.MapRoute(
13 | name: "Default",
14 | url: "{controller}/{action}/{id}",
15 | defaults: new { controller = "Facturas", action = "Index", id = UrlParameter.Optional }
16 | );
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Controllers/FacturasController.cs:
--------------------------------------------------------------------------------
1 | using MvcApplication.Entidades;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web.Mvc;
5 |
6 | namespace MvcApplication.Controllers
7 | {
8 | public class FacturasController : Controller
9 | {
10 | private static readonly ICollection facturas = new HashSet();
11 |
12 | private static readonly ICollection productos = new HashSet() {
13 | new Producto { Id = 1, Nombre = "Producto' A", Precio = 150 },
14 | new Producto { Id = 2, Nombre = "Producto B", Precio = 280 },
15 | new Producto { Id = 3, Nombre = "Producto C", Precio = 300 }
16 | };
17 |
18 | public ActionResult Index()
19 | {
20 | var modelo = facturas.ToArray();
21 | return View(modelo);
22 | }
23 |
24 | public ActionResult Create()
25 | {
26 | ViewBag.Productos = productos;
27 | return View();
28 | }
29 |
30 | public ActionResult Details(int id)
31 | {
32 | var modelo = facturas.FirstOrDefault(x => x.Id == id);
33 |
34 | if (modelo == null)
35 | {
36 | return HttpNotFound();
37 | }
38 |
39 | return View(modelo);
40 | }
41 |
42 | [HttpPost]
43 | public ActionResult Create(Factura modelo, string operacion = null)
44 | {
45 | if (ModelState.IsValid)
46 | {
47 | if (modelo.Detalle == null || modelo.Detalle.Count == 0)
48 | {
49 | ModelState.AddModelError("Detalle", "Debe agregar al menos un detalle para la factura");
50 | }
51 | else
52 | {
53 | facturas.Add(modelo);
54 | return RedirectToAction("Index");
55 | }
56 | }
57 |
58 | ViewBag.Productos = productos;
59 | return View(modelo);
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Entidades/Detalle.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace MvcApplication.Entidades
4 | {
5 | public class Detalle
6 | {
7 | public int FacturaId { get; set; }
8 |
9 | public int ProductoId { get; set; }
10 |
11 | [Range(0, 999999999)]
12 | public decimal Precio { get; set; }
13 |
14 | [Range(0, 999999999)]
15 | public decimal Cantidad { get; set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Entidades/Factura.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 |
5 | namespace MvcApplication.Entidades
6 | {
7 | public class Factura
8 | {
9 | public int Id { get; set; }
10 |
11 | public DateTime Fecha { get; set; }
12 |
13 | [Required]
14 | [RegularExpression("[0-9]+-[0-9kK]")]
15 | public string Nit { get; set; }
16 |
17 | [Required]
18 | public string ClienteNombre { get; set; }
19 |
20 | [Required]
21 | public ICollection Detalle { get; set; }
22 |
23 | public Factura()
24 | {
25 | this.Detalle = new HashSet();
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Entidades/Producto.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace MvcApplication.Entidades
4 | {
5 | public class Producto
6 | {
7 | public int Id { get; set; }
8 |
9 | [Required]
10 | public string Nombre { get; set; }
11 |
12 | [Range(0, 999999999)]
13 | public decimal Precio { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Extensions/MvcHtmlStringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 | using System.Web.Mvc;
3 |
4 | namespace MvcApplication.Extensions
5 | {
6 | public static class MvcHtmlStringExtensions
7 | {
8 | public static MvcHtmlString AddInputPrefix(this MvcHtmlString htmlString, string prefix)
9 | {
10 | // Estos son los nuevos formatos para los valores de los atributos "id" y "name"
11 | // de los inputs cuando tienen que ser colecciones o arreglos,
12 | // La idea es que el formato para los ids sea Propiedad_Indice_SubPropiedad y
13 | // que el formato para los names sea Propiedad[Indice].SubPropiedad.
14 |
15 | var newIdFormat = "$1=\"" + prefix + "_${index}_$2\"";
16 | var newNameFormat = "name=\"" + prefix + "[${index}].$1\"";
17 |
18 | var regexOptions = RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled;
19 |
20 | // idAttributeRegex para buscar textos que sean id="algo" o data-valmsg-for="algo",
21 | // nameAttributeRegex para buscar textos que sean name="algo".
22 | var idAttributeRegex = new Regex("(id|data-valmsg-for)=\"(.+?)\"", regexOptions);
23 | var nameAttributeRegex = new Regex("name=\"(.+?)\"", regexOptions);
24 |
25 | // Se remplazan los ids y names originales por el nuevo formato deseado.
26 | var html = htmlString.ToString();
27 | html = idAttributeRegex.Replace(html, newIdFormat);
28 | html = nameAttributeRegex.Replace(html, newNameFormat);
29 |
30 | // Si existe el atributo name="Propiedad[Indice].Index" se remplaza por el atributo
31 | // name="Propiedad[].Index"
32 | html = html.Replace("name=\"" + prefix + "[${index}].Index\"", "name=\"" + prefix + "[].Index\"");
33 |
34 | return new MvcHtmlString(html);
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="MvcApplication.MvcApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 | using System.Web.Routing;
3 |
4 | namespace MvcApplication
5 | {
6 | // Note: For instructions on enabling IIS6 or IIS7 classic mode,
7 | // visit http://go.microsoft.com/?LinkId=9394801
8 | public class MvcApplication : System.Web.HttpApplication
9 | {
10 | protected void Application_Start()
11 | {
12 | AreaRegistration.RegisterAllAreas();
13 |
14 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
15 | RouteConfig.RegisterRoutes(RouteTable.Routes);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("MvcApplication")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("MvcApplication")]
12 | [assembly: AssemblyCopyright("Copyright © 2013")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("96b815ff-a3a5-4253-b21d-a48759c90b17")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Revision and Build Numbers
32 | // by using the '*' as shown below:
33 | [assembly: AssemblyVersion("1.0.0.0")]
34 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Scripts/ViewModels/FacturaCreateViewModel.js:
--------------------------------------------------------------------------------
1 | var detalleViewModel = function () {
2 | var self = this;
3 |
4 | self.productoId = ko.observable(0);
5 | self.precio = ko.observable(0)
6 | self.cantidad = ko.observable(0);
7 |
8 | // se aplican las validaciones definidas en el html
9 | ko.validatedObservable(self);
10 | };
11 |
12 | var facturaViewModel = function () {
13 | var self = this;
14 |
15 | self.detalle = ko.observableArray();
16 |
17 | self.agregarDetalle = function () {
18 | self.detalle.push(new detalleViewModel());
19 | };
20 |
21 | self.eliminarDetalle = function (detalle) {
22 | self.detalle.remove(detalle);
23 | };
24 |
25 | self.canCreate = function () {
26 | var detallesValidos = self.detalle().length > 0;
27 |
28 | ko.utils.arrayForEach(self.detalle(), function (item) {
29 | detallesValidos = detallesValidos && item.isValid();
30 | });
31 |
32 | return detallesValidos;
33 | };
34 | };
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Scripts/_references.js:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 | ///
5 | ///
6 | ///
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Views/Facturas/Index.cshtml:
--------------------------------------------------------------------------------
1 | @model IEnumerable
2 |
3 | @{
4 | ViewBag.Title = "Index";
5 | }
6 |
7 | Listado de facturas
8 |
9 |
10 | @Html.ActionLink("Nueva Factura", "Create")
11 |
12 |
13 |
14 | |
15 | @Html.DisplayNameFor(model => model.Fecha)
16 | |
17 |
18 | @Html.DisplayNameFor(model => model.Nit)
19 | |
20 |
21 | @Html.DisplayNameFor(model => model.ClienteNombre)
22 | |
23 | |
24 |
25 |
26 | @foreach (var item in Model)
27 | {
28 |
29 | |
30 | @Html.DisplayFor(modelItem => item.Fecha)
31 | |
32 |
33 | @Html.DisplayFor(modelItem => item.Nit)
34 | |
35 |
36 | @Html.DisplayFor(modelItem => item.ClienteNombre)
37 | |
38 |
39 | @Html.ActionLink("Editar", "Edit", new { id = item.Id }) |
40 | @Html.ActionLink("Detalles", "Details", new { id = item.Id }) |
41 | @Html.ActionLink("Eliminar", "Delete", new { id = item.Id })
42 | |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Demo
7 |
8 |
9 |
10 | @RenderBody()
11 |
12 |
13 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "~/Views/Shared/_Layout.cshtml";
3 | }
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/dotNet/MaestroDetalleMVC4-02/MvcApplication/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/ManejoDeCache/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/ManejoDeCache.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebServices", "WebServices\WebServices.csproj", "{998FA187-4DBF-487B-9E23-D88607F6B752}"
5 | EndProject
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B01FBDBB-3C18-4A56-878A-94B7777113C0}"
7 | ProjectSection(SolutionItems) = preProject
8 | README.md = README.md
9 | EndProjectSection
10 | EndProject
11 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{5BABA9E8-FCA8-4733-A302-3E5540BC9DA4}"
12 | ProjectSection(SolutionItems) = preProject
13 | .nuget\NuGet.Config = .nuget\NuGet.Config
14 | .nuget\NuGet.exe = .nuget\NuGet.exe
15 | .nuget\NuGet.targets = .nuget\NuGet.targets
16 | EndProjectSection
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcApp", "MvcApp\MvcApp.csproj", "{C85B4B86-F8C7-48C6-A402-95C3DF03F23C}"
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|Any CPU = Debug|Any CPU
23 | Release|Any CPU = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {998FA187-4DBF-487B-9E23-D88607F6B752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {998FA187-4DBF-487B-9E23-D88607F6B752}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {998FA187-4DBF-487B-9E23-D88607F6B752}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {998FA187-4DBF-487B-9E23-D88607F6B752}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {C85B4B86-F8C7-48C6-A402-95C3DF03F23C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {C85B4B86-F8C7-48C6-A402-95C3DF03F23C}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {C85B4B86-F8C7-48C6-A402-95C3DF03F23C}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {C85B4B86-F8C7-48C6-A402-95C3DF03F23C}.Release|Any CPU.Build.0 = Release|Any CPU
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | EndGlobal
39 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/App_Start/FilterConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web;
2 | using System.Web.Mvc;
3 |
4 | namespace MvcApp
5 | {
6 | public class FilterConfig
7 | {
8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters)
9 | {
10 | filters.Add(new HandleErrorAttribute());
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/App_Start/RouteConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Mvc;
6 | using System.Web.Routing;
7 |
8 | namespace MvcApp
9 | {
10 | public class RouteConfig
11 | {
12 | public static void RegisterRoutes(RouteCollection routes)
13 | {
14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15 |
16 | routes.MapRoute(
17 | name: "Default",
18 | url: "{controller}/{action}/{id}",
19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20 | );
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/App_Start/WebApiConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web.Http;
5 |
6 | namespace MvcApp
7 | {
8 | public static class WebApiConfig
9 | {
10 | public static void Register(HttpConfiguration config)
11 | {
12 | config.Routes.MapHttpRoute(
13 | name: "DefaultApi",
14 | routeTemplate: "api/{controller}/{id}",
15 | defaults: new { id = RouteParameter.Optional }
16 | );
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using MvcApp.Servicios;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Web;
6 | using System.Web.Mvc;
7 |
8 | namespace MvcApp.Controllers
9 | {
10 | public class HomeController : Controller
11 | {
12 | public ActionResult Index(string usuario = null)
13 | {
14 | var servicio = new EmpresaServicio();
15 | var empresas = servicio.ObtenerPorUsuario(usuario);
16 |
17 | return View(empresas);
18 | }
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="MvcApp.MvcApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Http;
6 | using System.Web.Mvc;
7 | using System.Web.Routing;
8 |
9 | namespace MvcApp
10 | {
11 | // Note: For instructions on enabling IIS6 or IIS7 classic mode,
12 | // visit http://go.microsoft.com/?LinkId=9394801
13 | public class MvcApplication : System.Web.HttpApplication
14 | {
15 | protected void Application_Start()
16 | {
17 | AreaRegistration.RegisterAllAreas();
18 |
19 | WebApiConfig.Register(GlobalConfiguration.Configuration);
20 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
21 | RouteConfig.RegisterRoutes(RouteTable.Routes);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Models/Empresa.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 |
6 | namespace MvcApp.Models
7 | {
8 | public class Empresa
9 | {
10 | public int Id { get; set; }
11 |
12 | public string Nombre { get; set; }
13 |
14 | public string[] Usuarios { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MvcApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MvcApp")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("9e81224b-cc22-4ef6-a135-4d5b9117604f")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18051
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MvcApp.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 |
26 | [global::System.Configuration.ApplicationScopedSettingAttribute()]
27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28 | [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)]
29 | [global::System.Configuration.DefaultSettingValueAttribute("http://localhost:51344/ServiciosWeb/ServicioWebEmpresas.asmx")]
30 | public string MvcApp_ServicioWebEmpresas_ServicioWebEmpresas {
31 | get {
32 | return ((string)(this["MvcApp_ServicioWebEmpresas_ServicioWebEmpresas"]));
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | http://localhost:51344/ServiciosWeb/ServicioWebEmpresas.asmx
7 |
8 |
9 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Views/Home/Index.cshtml:
--------------------------------------------------------------------------------
1 | @model IEnumerable
2 |
3 | @{
4 | Layout = null;
5 | }
6 |
7 |
8 |
9 |
10 |
11 |
12 | Index
13 |
14 |
15 |
16 | @using (Html.BeginForm())
17 | {
18 |
26 |
27 |
28 |
29 | }
30 |
31 | @if(Model != null && Model.Count() > 0)
32 | {
33 |
34 |
35 | |
36 | @Html.DisplayNameFor(model => model.Id)
37 | |
38 |
39 | @Html.DisplayNameFor(model => model.Nombre)
40 | |
41 |
42 |
43 | @foreach (var item in Model) {
44 |
45 | |
46 | @Html.DisplayFor(modelItem => item.Id)
47 | |
48 |
49 | @Html.DisplayFor(modelItem => item.Nombre)
50 | |
51 |
52 | }
53 |
54 |
55 | }
56 |
57 |
58 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Web References/ServicioWebEmpresas/Empresa.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | MvcApp.ServicioWebEmpresas.Empresa, Web References.ServicioWebEmpresas.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Web References/ServicioWebEmpresas/Reference.map:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Web References/ServicioWebEmpresas/ServicioWebEmpresas.disco:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/MvcApp/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/ManejoDeCache/README.md
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/WebServices/Entidades/Empresa.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 |
6 | namespace WebServices.Entidades
7 | {
8 | public class Empresa
9 | {
10 | public int Id { get; set; }
11 | public string Nombre { get; set; }
12 | public string[] Usuarios { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/WebServices/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WebServices")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WebServices")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("3cf4252b-6ab9-42e8-a927-10a4fd11ae21")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/WebServices/ServiciosWeb/ServicioWebEmpresas.asmx:
--------------------------------------------------------------------------------
1 | <%@ WebService Language="C#" CodeBehind="ServicioWebEmpresas.asmx.cs" Class="WebServices.ServiciosWeb.ServicioWebEmpresas" %>
2 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/WebServices/ServiciosWeb/ServicioWebEmpresas.asmx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Services;
6 | using WebServices.Entidades;
7 |
8 | namespace WebServices.ServiciosWeb
9 | {
10 | ///
11 | /// Summary description for ServicioEmpresas
12 | ///
13 | [WebService(Namespace = "http://miguelerm.github.io/samples/serviciosweb")]
14 | [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
15 | [System.ComponentModel.ToolboxItem(false)]
16 | [System.Web.Script.Services.ScriptService]
17 | public class ServicioWebEmpresas : System.Web.Services.WebService
18 | {
19 |
20 | private readonly IEnumerable empresas = new[] {
21 | new Empresa { Id = 1, Nombre = "Empresa 1", Usuarios = new [] {"usuario1", "usuario2", "usuario3"} },
22 | new Empresa { Id = 2, Nombre = "Empresa 2", Usuarios = new [] {"usuario1"} },
23 | new Empresa { Id = 3, Nombre = "Empresa 3", Usuarios = new [] {"usuario2"} },
24 | new Empresa { Id = 4, Nombre = "Empresa 4", Usuarios = new [] {"usuario3"} },
25 | new Empresa { Id = 5, Nombre = "Empresa 5", Usuarios = new [] {"usuario2", "usuario3"} },
26 | new Empresa { Id = 6, Nombre = "Empresa 6", Usuarios = new [] {"usuario1", "usuario3"} },
27 | new Empresa { Id = 7, Nombre = "Empresa 7", Usuarios = new [] {"usuario1", "usuario2"} }
28 | };
29 |
30 | [WebMethod]
31 | public Empresa[] ObtenerPorUsuario(string usuario)
32 | {
33 | // se retornan las empresas que apliquen para el usuario indicado.
34 | return empresas.Where(empresa => empresa.Usuarios.Contains(usuario)).ToArray();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/WebServices/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/WebServices/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/dotNet/ManejoDeCache/WebServices/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MultipleFilesUpload.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30723.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcDemo-01", "MvcDemo-01\MvcDemo-01.csproj", "{51FDCCC1-7790-476A-985B-CBF29F747A80}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {51FDCCC1-7790-476A-985B-CBF29F747A80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {51FDCCC1-7790-476A-985B-CBF29F747A80}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {51FDCCC1-7790-476A-985B-CBF29F747A80}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {51FDCCC1-7790-476A-985B-CBF29F747A80}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/App_Start/RouteConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Mvc;
6 | using System.Web.Routing;
7 |
8 | namespace MvcDemo_01
9 | {
10 | public class RouteConfig
11 | {
12 | public static void RegisterRoutes(RouteCollection routes)
13 | {
14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15 |
16 | routes.MapRoute(
17 | name: "Default",
18 | url: "{controller}/{action}/{id}",
19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20 | );
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using MvcDemo_01.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Web;
7 | using System.Web.Mvc;
8 |
9 | namespace MvcDemo_01.Controllers
10 | {
11 | public class HomeController : Controller
12 | {
13 | // GET: Home
14 | public ActionResult Index()
15 | {
16 |
17 | var root = Server.MapPath("~/App_Data/Archivos");
18 | if (!Directory.Exists(root))
19 | {
20 | Directory.CreateDirectory(root);
21 | }
22 | ViewBag.Archivos = Directory.GetFiles(root, "*.*", SearchOption.AllDirectories);
23 |
24 | return View();
25 | }
26 |
27 | public ActionResult CargarArchivos(CargarArchivoModel[] archivos)
28 | {
29 | if (archivos == null || archivos.Length == 0)
30 | {
31 | return RedirectToAction("Index");
32 | }
33 |
34 | var root = Server.MapPath("~/App_Data/Archivos");
35 |
36 | foreach (var item in archivos)
37 | {
38 |
39 | if (item.Archivo == null)
40 | {
41 | continue;
42 | }
43 |
44 | var path = Path.Combine(root, item.Tipo);
45 |
46 | if (!Directory.Exists(path))
47 | {
48 | Directory.CreateDirectory(path);
49 | }
50 |
51 | item.Archivo.SaveAs(Path.Combine(path, Path.GetFileName(item.Archivo.FileName)));
52 |
53 | }
54 |
55 | return RedirectToAction("Index");
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="MvcDemo_01.MvcApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Mvc;
6 | using System.Web.Routing;
7 |
8 | namespace MvcDemo_01
9 | {
10 | public class MvcApplication : System.Web.HttpApplication
11 | {
12 | protected void Application_Start()
13 | {
14 | AreaRegistration.RegisterAllAreas();
15 | RouteConfig.RegisterRoutes(RouteTable.Routes);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Models/CargarArchivoModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 |
6 | namespace MvcDemo_01.Models
7 | {
8 | public class CargarArchivoModel
9 | {
10 | public string Tipo { get; set; }
11 | public HttpPostedFileBase Archivo { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MvcDemo_01")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MvcDemo_01")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d875d585-477d-46c5-b81e-acc978713c17")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Scripts/main.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | $(function () {
4 |
5 | var correlativo = 0;
6 |
7 | $('#btn-agregar').click(function (e) {
8 | e.preventDefault();
9 |
10 | var $fila = $('
');
11 | var $celdaA = $(' | ');
12 | var $celdaB = $(' | ');
13 | var $celdaC = $(' | ');
14 |
15 | var prefijo = 'archivos[' + correlativo + ']';
16 |
17 | var $hidden = $('', { type: 'hidden', value: correlativo, name: 'archivos.index' });
18 | var $dropDown = $('', { name: prefijo + '.tipo' });
19 | var $inputFile = $('', { name: prefijo + '.archivo', type: 'file' });
20 | var $delete = $('', { type: 'button', class: 'pure-button' }).text('Eliminar');
21 |
22 |
23 | $dropDown.append($('', { value: 'A', text: 'Tipo "A"' }));
24 | $dropDown.append($('', { value: 'B', text: 'Tipo "B"' }));
25 | $dropDown.append($('', { value: 'C', text: 'Tipo "C"' }));
26 |
27 | $celdaC.append($delete);
28 | $celdaB.append($inputFile);
29 | $celdaA.append($dropDown);
30 |
31 | $fila.append([$celdaA, $celdaB, $celdaC]);
32 |
33 | $('#tbl-archivos').append($fila);
34 |
35 | $delete.click(function (_e) {
36 | _e.preventDefault();
37 | $fila.remove();
38 | })
39 |
40 | correlativo++;
41 |
42 | $inputFile.click();
43 |
44 | });
45 |
46 | })
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Views/Home/Index.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = null;
3 | }
4 |
5 |
6 |
7 |
8 |
9 |
10 | Index
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | | Archivo |
20 |
21 |
22 |
23 | @foreach (var archivo in ViewBag.Archivos)
24 | {
25 |
26 | | @archivo |
27 |
28 | }
29 |
30 |
31 |
32 |
33 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Views/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/MvcDemo-01/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/dotNet/MultipleFilesUpload/README.md:
--------------------------------------------------------------------------------
1 | Multiple File Upload With Asp.Net MVC
2 | =====================================
3 |
4 | Ejemplo de carga de multiples archivos utilizando Asp.Net Mvc.
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (web)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/dotnetcore-cache-sample.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}",
16 | "stopAtEntry": false,
17 | "internalConsoleOptions": "openOnSessionStart",
18 | "launchBrowser": {
19 | "enabled": true,
20 | "args": "${auto-detect-url}",
21 | "windows": {
22 | "command": "cmd.exe",
23 | "args": "/C start ${auto-detect-url}"
24 | },
25 | "osx": {
26 | "command": "open"
27 | },
28 | "linux": {
29 | "command": "xdg-open"
30 | }
31 | },
32 | "env": {
33 | "ASPNETCORE_ENVIRONMENT": "Development"
34 | },
35 | "sourceFileMap": {
36 | "/Views": "${workspaceFolder}/Views"
37 | }
38 | },
39 | {
40 | "name": ".NET Core Attach",
41 | "type": "coreclr",
42 | "request": "attach",
43 | "processId": "${command:pickProcess}"
44 | }
45 | ,]
46 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/dotnetcore-cache-sample.csproj"
11 | ],
12 | "problemMatcher": "$msCompile"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Controllers/BooksAsyncController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 | using Samples.CacheSample.Models;
7 | using Samples.CacheSample.Repositories;
8 |
9 | namespace Samples.CacheSample.Controllers
10 | {
11 | [Route("api/[controller]")]
12 | public class BooksAsyncController : Controller
13 | {
14 | private readonly IBooksAsyncRepository books;
15 |
16 | public BooksAsyncController(IBooksAsyncRepository books)
17 | {
18 | this.books = books;
19 | }
20 |
21 | [HttpGet]
22 | public async Task GetAsync()
23 | {
24 | return Ok(await books.GetAllAsync());
25 | }
26 |
27 | [HttpGet("{id}")]
28 | public async Task GetAsync(int id)
29 | {
30 | var book = await books.GetSingleAsync(id);
31 |
32 | if (book == null) {
33 | return NotFound();
34 | }
35 |
36 | return Ok(book);
37 | }
38 |
39 | [HttpPost]
40 | public async Task PostAsync(CreateOrUpdateBookModel model)
41 | {
42 | if (!ModelState.IsValid) {
43 | return BadRequest(ModelState);
44 | }
45 |
46 | var title = model.Title;
47 | var author = model.Author;
48 | var year = model.Year;
49 | var id = await books.AddAsync(title, author, year);
50 | if (id <= 0) {
51 | return StatusCode(500);
52 | }
53 |
54 | return CreatedAtAction("Get", new { id, title });
55 | }
56 |
57 | [HttpPut("{id}")]
58 | public async Task PutAsync(int id, CreateOrUpdateBookModel model)
59 | {
60 | if (!ModelState.IsValid) {
61 | return BadRequest(ModelState);
62 | }
63 |
64 | var title = model.Title;
65 | var author = model.Author;
66 | var year = model.Year;
67 | var updated = await books.UpdateAsync(id, title, author, year);
68 |
69 | if (!updated) {
70 | return StatusCode(500);
71 | }
72 |
73 | return NoContent();
74 | }
75 |
76 | [HttpDelete("{id}")]
77 | public async Task DeleteAsync(int id)
78 | {
79 | var deleted = await books.DeleteAsync(id);
80 |
81 | if (!deleted) {
82 | return StatusCode(500);
83 | }
84 |
85 | return NoContent();
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Controllers/BooksController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 | using Samples.CacheSample.Models;
7 | using Samples.CacheSample.Repositories;
8 |
9 | namespace Samples.CacheSample.Controllers
10 | {
11 | [Route("api/[controller]")]
12 | public class BooksController : Controller
13 | {
14 | private readonly IBooksRepository books;
15 |
16 | public BooksController(IBooksRepository books)
17 | {
18 | this.books = books;
19 | }
20 |
21 | [HttpGet]
22 | public IActionResult Get()
23 | {
24 | return Ok(books.GetAll());
25 | }
26 |
27 | [HttpGet("{id}")]
28 | public IActionResult Get(int id)
29 | {
30 | var book = books.GetSingle(id);
31 |
32 | if (book == null) {
33 | return NotFound();
34 | }
35 |
36 | return Ok(book);
37 | }
38 |
39 | [HttpPost]
40 | public IActionResult Post(CreateOrUpdateBookModel model)
41 | {
42 | if (!ModelState.IsValid) {
43 | return BadRequest(ModelState);
44 | }
45 |
46 | var title = model.Title;
47 | var author = model.Author;
48 | var year = model.Year;
49 | var id = books.Add(title, author, year);
50 | if (id <= 0) {
51 | return StatusCode(500);
52 | }
53 |
54 | return CreatedAtAction("Get", new { id, title });
55 | }
56 |
57 | [HttpPut("{id}")]
58 | public IActionResult Put(int id, CreateOrUpdateBookModel model)
59 | {
60 | if (!ModelState.IsValid) {
61 | return BadRequest(ModelState);
62 | }
63 |
64 | var title = model.Title;
65 | var author = model.Author;
66 | var year = model.Year;
67 | var updated = books.Update(id, title, author, year);
68 |
69 | if (!updated) {
70 | return StatusCode(500);
71 | }
72 |
73 | return NoContent();
74 | }
75 |
76 | [HttpDelete("{id}")]
77 | public IActionResult Delete(int id)
78 | {
79 | var deleted = books.Delete(id);
80 |
81 | if (!deleted) {
82 | return StatusCode(500);
83 | }
84 |
85 | return NoContent();
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Entities/Book.cs:
--------------------------------------------------------------------------------
1 | namespace Samples.CacheSample.Entities {
2 | public class Book {
3 | public int Id { get; set; }
4 | public string Title { get; set; }
5 | public string Author { get; set; }
6 | public int Year { get; set; }
7 | }
8 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Models/CreateOrUpdateBookModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace Samples.CacheSample.Models {
4 | public class CreateOrUpdateBookModel {
5 | [Required]
6 | [StringLength(500)]
7 | [MinLength(1)]
8 | public string Title { get; set; }
9 |
10 | [Required]
11 | [StringLength(500)]
12 | [MinLength(1)]
13 | public string Author { get; set; }
14 |
15 | public int Year { get; set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Logging;
10 |
11 | namespace Samples.CacheSample
12 | {
13 | public class Program
14 | {
15 | public static void Main(string[] args)
16 | {
17 | BuildWebHost(args).Run();
18 | }
19 |
20 | public static IWebHost BuildWebHost(string[] args) =>
21 | WebHost.CreateDefaultBuilder(args)
22 | .UseStartup()
23 | .Build();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/DbSchema.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 | using Microsoft.Extensions.Logging;
5 |
6 | namespace Samples.CacheSample.Repositories {
7 | public class DbSchema {
8 | private readonly IConnectionProvider connectionProvider;
9 | private readonly ILogger logger;
10 |
11 | public DbSchema(IConnectionProvider connectionProvider, ILogger logger)
12 | {
13 | this.connectionProvider = connectionProvider;
14 | this.logger = logger;
15 | }
16 |
17 | public void Crear() {
18 | logger.LogDebug("Creating Database Schema...");
19 | using(var cnn = connectionProvider.OpenConnection())
20 | {
21 | var command = cnn.CreateCommand();
22 | command.CommandText = GetDatabaseSchemaScript();
23 | command.ExecuteNonQuery();
24 | }
25 | logger.LogDebug("Database Schema Created.");
26 | }
27 |
28 | private static string GetDatabaseSchemaScript() {
29 | const string resourceName = "dotnetcore-cache-sample.Resources.database-schema.sql";
30 | var resourceAssembly = typeof(DbSchema).Assembly;
31 | var resourceStream = resourceAssembly.GetManifestResourceStream(resourceName);
32 |
33 | if (resourceStream == null) {
34 | var resourceNames = string.Join(", ", resourceAssembly.GetManifestResourceNames());
35 | throw new ApplicationException($"Resource {resourceName} do not exists on the assembly {resourceAssembly.FullName}. Available resouces: {resourceNames}.");
36 | }
37 |
38 | using (var reader = new StreamReader(resourceStream, Encoding.UTF8))
39 | {
40 | return reader.ReadToEnd();
41 | }
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/IBooksAsyncRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Samples.CacheSample.Entities;
3 |
4 | namespace Samples.CacheSample.Repositories {
5 | public interface IBooksAsyncRepository
6 | {
7 | Task AddAsync(string title, string author, int year);
8 | Task UpdateAsync(int id, string title, string author, int year);
9 | Task DeleteAsync(int id);
10 | Task GetAllAsync();
11 | Task GetSingleAsync(int id);
12 | }
13 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/IBooksRepository.cs:
--------------------------------------------------------------------------------
1 | using Samples.CacheSample.Entities;
2 |
3 | namespace Samples.CacheSample.Repositories
4 | {
5 | public interface IBooksRepository
6 | {
7 | int Add(string title, string author, int year);
8 | bool Update(int id, string title, string author, int year);
9 | bool Delete(int id);
10 | Book[] GetAll();
11 | Book GetSingle(int id);
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/IConnectionAsyncProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using System.Threading.Tasks;
3 |
4 | namespace Samples.CacheSample.Repositories {
5 | public interface IConnectionAsyncProvider
6 | {
7 | Task OpenConnectionAsync();
8 | }
9 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/IConnectionProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 |
3 | namespace Samples.CacheSample.Repositories {
4 | public interface IConnectionProvider
5 | {
6 | IDbConnection OpenConnection();
7 | }
8 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/SqliteBooksAsyncRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Samples.CacheSample.Entities;
3 |
4 | namespace Samples.CacheSample.Repositories {
5 | public class BooksSqliteAsyncRepository : IBooksAsyncRepository
6 | {
7 | public Task AddAsync(string title, string author, int year)
8 | {
9 | throw new System.NotImplementedException();
10 | }
11 |
12 | public Task DeleteAsync(int id)
13 | {
14 | throw new System.NotImplementedException();
15 | }
16 |
17 | public Task GetAllAsync()
18 | {
19 | throw new System.NotImplementedException();
20 | }
21 |
22 | public Task GetSingleAsync(int id)
23 | {
24 | throw new System.NotImplementedException();
25 | }
26 |
27 | public Task UpdateAsync(int id, string title, string author, int year)
28 | {
29 | throw new System.NotImplementedException();
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/SqliteBooksRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Samples.CacheSample.Entities;
3 |
4 | namespace Samples.CacheSample.Repositories {
5 | public class BooksSqliteRepository : IBooksRepository
6 | {
7 | public int Add(string title, string author, int year)
8 | {
9 | throw new System.NotImplementedException();
10 | }
11 |
12 | public bool Delete(int id)
13 | {
14 | throw new System.NotImplementedException();
15 | }
16 |
17 | public Book[] GetAll()
18 | {
19 | throw new System.NotImplementedException();
20 | }
21 |
22 | public Book GetSingle(int id)
23 | {
24 | throw new System.NotImplementedException();
25 | }
26 |
27 | public bool Update(int id, string title, string author, int year)
28 | {
29 | throw new System.NotImplementedException();
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/SqliteConnectionProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using System.Threading.Tasks;
3 | using Microsoft.Data.Sqlite;
4 | using Microsoft.Extensions.Options;
5 |
6 | namespace Samples.CacheSample.Repositories {
7 | public class SqliteConnectionProvider : IConnectionProvider, IConnectionAsyncProvider
8 | {
9 | private readonly string connectionString;
10 |
11 | public SqliteConnectionProvider(IOptions options)
12 | {
13 | this.connectionString = options.Value.ConnectionString;
14 | }
15 |
16 | public IDbConnection OpenConnection()
17 | {
18 | var conn = CreateConnection();
19 | conn.Open();
20 | return conn;
21 | }
22 |
23 | public async Task OpenConnectionAsync()
24 | {
25 | var conn = CreateConnection();
26 | await conn.OpenAsync();
27 | return conn;
28 | }
29 |
30 | private SqliteConnection CreateConnection() {
31 | return new SqliteConnection(connectionString);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Repositories/SqliteOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Samples.CacheSample.Repositories {
2 | public class SqliteOptions
3 | {
4 | public string ConnectionString { get; set; }
5 | }
6 | }
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.Logging;
10 | using Microsoft.Extensions.Options;
11 | using Samples.CacheSample.Repositories;
12 |
13 | namespace Samples.CacheSample
14 | {
15 | public class Startup
16 | {
17 | public Startup(IConfiguration configuration)
18 | {
19 | Configuration = configuration;
20 | }
21 |
22 | public IConfiguration Configuration { get; }
23 |
24 | // This method gets called by the runtime. Use this method to add services to the container.
25 | public void ConfigureServices(IServiceCollection services)
26 | {
27 | services.AddTransient();
28 |
29 | services.AddTransient();
30 | services.AddTransient();
31 | services.Decorate();
32 |
33 | services.AddTransient();
34 | services.AddTransient();
35 | services.Decorate();
36 |
37 | services.AddLogging();
38 | services.AddMemoryCache();
39 | services.AddMvc();
40 |
41 | services.Configure(options => {
42 | options.ConnectionString = Configuration.GetConnectionString("DefaultConnectionString");
43 | });
44 | }
45 |
46 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
47 | public void Configure(IApplicationBuilder app, IHostingEnvironment env)
48 | {
49 | if (env.IsDevelopment())
50 | {
51 | app.UseDeveloperExceptionPage();
52 | }
53 |
54 | app.UseMvc();
55 |
56 | using(var startupScope = app.ApplicationServices.CreateScope()) {
57 | var schema = startupScope.ServiceProvider.GetRequiredService();
58 | schema.Crear();
59 | }
60 |
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Debug",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "DefaultConnectionString": "Data Source=:memory:"
4 | },
5 | "Logging": {
6 | "IncludeScopes": false,
7 | "Debug": {
8 | "LogLevel": {
9 | "Default": "Warning"
10 | }
11 | },
12 | "Console": {
13 | "LogLevel": {
14 | "Default": "Warning"
15 | }
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/dotNet/dotnetcore-cache-sample/dotnetcore-cache-sample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Controllers/PingController.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Http;
2 |
3 | namespace Api.Controllers
4 | {
5 | public class PingController : ApiController
6 | {
7 | private string GetUserDisplayName()
8 | {
9 | return $"{User.GetEmailAddress()} - {User.GetGivenName()} {User.GetSurname()}";
10 | }
11 |
12 | public IHttpActionResult Get()
13 | {
14 | return Ok($"Pong [GET] ({GetUserDisplayName()})");
15 | }
16 |
17 | public IHttpActionResult Post()
18 | {
19 | return Ok($"Pong [POST] ({GetUserDisplayName()})");
20 | }
21 |
22 | public IHttpActionResult Put()
23 | {
24 | return Ok($"Pong [PUT] ({GetUserDisplayName()})");
25 | }
26 |
27 | public IHttpActionResult Patch()
28 | {
29 | return Ok($"Pong [PATCH] ({GetUserDisplayName()})");
30 | }
31 |
32 | public IHttpActionResult Delete()
33 | {
34 | return Ok($"Pong [DELETE] ({GetUserDisplayName()})");
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Controllers/ProductosController.cs:
--------------------------------------------------------------------------------
1 | using Api.Servicios;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Web;
6 | using System.Web.Http;
7 |
8 | namespace Api.Controllers
9 | {
10 | public class ProductosController : ApiController
11 | {
12 | private readonly ProductoServicio productos;
13 |
14 | public ProductosController()
15 | {
16 | productos = new ProductoServicio();
17 | }
18 |
19 | public IHttpActionResult Get(int pagina = 1, int elementos = 20)
20 | {
21 | return Ok(productos.ObtenerTodos(pagina, elementos));
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Entidades/Factura.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.ComponentModel.DataAnnotations.Schema;
5 | using System.Linq;
6 | using System.Web;
7 |
8 | namespace Api.Entidades
9 | {
10 | [Table("Facturas")]
11 | public class Factura
12 | {
13 | public int Id { get; set; }
14 | public DateTime Fecha { get; set; }
15 |
16 | [StringLength(20)]
17 | public string Nit { get; set; }
18 |
19 | [StringLength(300)]
20 | public string Nombre { get; set; }
21 |
22 | public ICollection Detalles { get; set; }
23 |
24 | public Factura()
25 | {
26 | Fecha = DateTime.UtcNow;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Entidades/FacturaDetalle.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations.Schema;
2 |
3 | namespace Api.Entidades
4 | {
5 | [Table("FacturaDetalles")]
6 | public class FacturaDetalle
7 | {
8 | public int Id { get; set; }
9 |
10 | public int FacturaId { get; set; }
11 |
12 | [ForeignKey("FacturaId")]
13 | public Factura Factura { get; set; }
14 |
15 | public int ProductoId { get; set; }
16 |
17 | [ForeignKey("ProductoId")]
18 | public Producto Producto { get; set; }
19 |
20 | public decimal Cantidad { get; set; }
21 |
22 | public decimal Precio { get; set; }
23 |
24 | }
25 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Entidades/Producto.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 |
4 | namespace Api.Entidades
5 | {
6 | [Table("Productos")]
7 | public class Producto
8 | {
9 | public int Id { get; set; }
10 |
11 | [Required]
12 | [StringLength(50)]
13 | public string Codigo { get; set; }
14 |
15 | [Required]
16 | [StringLength(200)]
17 | public string Nombre { get; set; }
18 |
19 | [StringLength(3000)]
20 | public string Descripcion { get; set; }
21 |
22 | [Range(0, 999999999)]
23 | public decimal Existencia { get; set; }
24 |
25 | [Range(0, 999999999)]
26 | public decimal PrecioBase { get; set; }
27 | }
28 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("api")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("api")]
12 | [assembly: AssemblyCopyright("Copyright © 2016")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("e98942c9-a3c7-4c6c-bc80-792a59469072")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Revision and Build Numbers
32 | // by using the '*' as shown below:
33 | [assembly: AssemblyVersion("1.0.0.0")]
34 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Repositorios/BaseDeDatos.cs:
--------------------------------------------------------------------------------
1 | using Api.Entidades;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Data.Entity;
5 | using System.Linq;
6 | using System.Web;
7 |
8 | namespace Api.Repositorios
9 | {
10 | public class BaseDeDatos : DbContext
11 | {
12 | public DbSet Facturas { get; set; }
13 | public DbSet FacturaDetalles { get; set; }
14 | public DbSet Productos { get; set; }
15 |
16 | static BaseDeDatos()
17 | {
18 | // Esto para que Entity Framework nunca intente crear la base de datos.
19 | // se asume que la base de datos ya existirá.
20 | Database.SetInitializer(new NullDatabaseInitializer());
21 | }
22 |
23 | public BaseDeDatos() : base("CadenaDeConexion")
24 | {
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Repositorios/ProductosRepositorio.cs:
--------------------------------------------------------------------------------
1 | using Api.Entidades;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Web;
6 |
7 | namespace Api.Repositorios
8 | {
9 | public class ProductosRepositorio
10 | {
11 | private readonly BaseDeDatos db;
12 |
13 | public ProductosRepositorio()
14 | {
15 | db = new BaseDeDatos();
16 | }
17 |
18 | public IEnumerable ObtenerTodos(int skip = 0, int take = 20)
19 | {
20 | return db.Productos.OrderBy(x => x.Nombre).Skip(skip).Take(take).ToList();
21 | }
22 |
23 | public int ContarTodos()
24 | {
25 | return db.Productos.Count();
26 | }
27 |
28 | public Producto BuscarPorCodigo(string codigo)
29 | {
30 | return db.Productos.FirstOrDefault(x => x.Codigo == codigo);
31 | }
32 |
33 | public Producto BuscarPorId(int id)
34 | {
35 | return db.Productos.SingleOrDefault(x => x.Id == id);
36 | }
37 |
38 | public int Crear(Producto producto)
39 | {
40 | db.Productos.Add(producto);
41 | db.SaveChanges();
42 | return producto.Id;
43 | }
44 |
45 | public bool Editar(Producto producto)
46 | {
47 | db.Entry(producto).State = System.Data.Entity.EntityState.Modified;
48 | return db.SaveChanges() > 0;
49 | }
50 |
51 | public bool Eliminar(int id)
52 | {
53 | var producto = BuscarPorId(id);
54 | if (producto != null)
55 | {
56 | db.Productos.Remove(producto);
57 | return db.SaveChanges() > 0;
58 | }
59 | else
60 | {
61 | return false;
62 | }
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Servicios/ProductoServicio.cs:
--------------------------------------------------------------------------------
1 | using Api.Entidades;
2 | using Api.Repositorios;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Web;
7 |
8 | namespace Api.Servicios
9 | {
10 | public class ProductoServicio
11 | {
12 | private readonly ProductosRepositorio productos;
13 |
14 | public ProductoServicio()
15 | {
16 | productos = new ProductosRepositorio();
17 | }
18 |
19 | public IEnumerable ObtenerTodos(int pagina = 1, int elementosPorPagina = 20)
20 | {
21 | if (pagina < 1) throw new ArgumentOutOfRangeException("La pagina no puede ser menor a 1");
22 | if (elementosPorPagina < 1) throw new ArgumentOutOfRangeException("El valor indicado para los elementos por pagina es inválido");
23 | if (elementosPorPagina > 500) throw new ArgumentOutOfRangeException("Por motivos de rendimiento no se permite obtener mas de 500 registros en una sola petición");
24 |
25 | var cantidadDeProductos = productos.ContarTodos();
26 |
27 | var ultimaPagina = Math.Ceiling((double)cantidadDeProductos / elementosPorPagina);
28 |
29 | if (pagina > ultimaPagina)throw new ArgumentOutOfRangeException($"La pagina no puede ser mayor a {ultimaPagina}.");
30 |
31 | var skip = (pagina - 1) * elementosPorPagina;
32 | var take = elementosPorPagina;
33 |
34 | return productos.ObtenerTodos(skip, take);
35 | }
36 |
37 | }
38 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Startup.cs:
--------------------------------------------------------------------------------
1 | using IdentityServer3.AccessTokenValidation;
2 | using Newtonsoft.Json.Serialization;
3 | using Owin;
4 | using System.Web.Http;
5 | using System.Web.Http.Cors;
6 |
7 | namespace Api
8 | {
9 | public class Startup
10 | {
11 | public void Configuration(IAppBuilder app)
12 | {
13 | var authUrl = "http://localhost:51901";
14 | var appUrl = "http://localhost:51900";
15 |
16 | app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
17 | {
18 | Authority = authUrl,
19 | ClientId = "spa",
20 | ClientSecret = "59D8076E-A7B4-4348-9B02-F358A869E3B8",
21 |
22 | RequiredScopes = new[] { "api" }
23 | });
24 |
25 | var config = new HttpConfiguration();
26 |
27 | config.MapHttpAttributeRoutes();
28 | config.Routes.MapHttpRoute("default", "api/{controller}/{id}", new { Id = RouteParameter.Optional });
29 | config.EnableCors(new EnableCorsAttribute(appUrl, "*", "*"));
30 | config.Filters.Add(new AuthorizeAttribute());
31 |
32 | config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
33 |
34 | app.UseWebApi(config);
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/UserExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Security.Principal;
3 |
4 | namespace Api
5 | {
6 | public static class UserExtensions
7 | {
8 | private static class ClaimTypes
9 | {
10 | private const string Schema = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/";
11 | public const string NameIdentifier = Schema + "nameidentifier";
12 | public const string GivenName = Schema + "givenname";
13 | public const string Surname = Schema + "surname";
14 | public const string EmailAddress = Schema + "emailaddress";
15 | }
16 |
17 | public static string GetGivenName(this IPrincipal user)
18 | {
19 | return GetClaimFirstValue(user, ClaimTypes.GivenName);
20 | }
21 |
22 | public static string GetSurname(this IPrincipal user)
23 | {
24 | return GetClaimFirstValue(user, ClaimTypes.Surname);
25 | }
26 |
27 | public static string GetEmailAddress(this IPrincipal user)
28 | {
29 | return GetClaimFirstValue(user, ClaimTypes.EmailAddress);
30 | }
31 |
32 | public static string GetNameIdentifier(this IPrincipal user)
33 | {
34 | return GetClaimFirstValue(user, ClaimTypes.NameIdentifier);
35 | }
36 |
37 | private static string GetClaimFirstValue(IPrincipal user, string claimType)
38 | {
39 | return (user as System.Security.Claims.ClaimsPrincipal)?
40 | .Claims?
41 | .FirstOrDefault(x => x.Type == claimType)
42 | ?.Value;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/api/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/Content/jasmine/jasmine_favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/Content/jasmine/jasmine_favicon.png
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("app")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("app")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("62173c8d-1ae4-4848-9afa-8707d830a32c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/Scripts/_references.js:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 | ///
5 | ///
6 | ///
7 | ///
8 | ///
9 | ///
10 | ///
11 | ///
12 | ///
13 | ///
14 | ///
15 | ///
16 | ///
17 | ///
18 | ///
19 | ///
20 | ///
21 | ///
22 | ///
23 | ///
24 | ///
25 | ///
26 | ///
27 | ///
28 | ///
29 | ///
30 | ///
31 | ///
32 | ///
33 | ///
34 | ///
35 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/app.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app", ["ui.router", "ui.bootstrap"]).run(setTitle);
3 |
4 | function setTitle($rootScope) {
5 | $rootScope.title = "App";
6 | }
7 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/auth.js:
--------------------------------------------------------------------------------
1 | var auth = (function () {
2 | var _user = JSON.parse(sessionStorage.getItem("user") || null);
3 | var _authSetting = JSON.parse(sessionStorage.getItem("oidc-config") || null);
4 | var mgr;
5 |
6 | init();
7 |
8 | return {
9 | redirectToSignIn: redirectToSignIn,
10 | currentUser: currentUser,
11 | getUser: getUser
12 | };
13 |
14 | function init() {
15 | if (!_user || !_authSetting) {
16 | redirectToSignIn();
17 | return;
18 | }
19 |
20 | mgr = new Oidc.UserManager(_authSetting)
21 |
22 | mgr.events.addUserLoaded(function (u) {
23 | _user = u;
24 | });
25 |
26 | mgr.events.addUserUnloaded(function () {
27 | _user = null;
28 | redirectToSignOut();
29 | });
30 |
31 | mgr.events.addAccessTokenExpiring(function () {
32 | console.log("token expiring");
33 | console.log(_user.access_token);
34 | });
35 |
36 | mgr.events.addAccessTokenExpired(function () {
37 | console.log("token expired");
38 | });
39 |
40 | mgr.events.addSilentRenewError(function (e) {
41 | console.log("silent renew error", e.message);
42 | });
43 |
44 | window.onmessage = function (e) {
45 | if (e.origin === window.location.protocol + "//" + window.location.host && e.data === "changed") {
46 | console.log("user session has changed");
47 | mgr.removeUser();
48 | mgr.signinSilent().then(function () {
49 | // Session state changed but we managed to silently get a new identity token, everything's fine
50 | console.log('renewTokenSilentAsync success');
51 | }).catch(function (err) {
52 | // Here we couldn't get a new identity token, we have to ask the user to log in again
53 | console.log('renewTokenSilentAsync failed', err.message);
54 | });
55 | }
56 | }
57 | }
58 |
59 | function redirectToSignIn() {
60 | window.location.href = window.location.protocol + "//" + window.location.host + "/signin.html";
61 | }
62 |
63 | function redirectToSignOut() {
64 | window.location.href = window.location.protocol + "//" + window.location.host + "/signedout.html";
65 | }
66 |
67 | function currentUser() {
68 | return _user;
69 | }
70 |
71 | function setUser(user) {
72 | _user = user;
73 | }
74 |
75 | function getUser() {
76 | return mgr.getUser();
77 | }
78 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/boot.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | auth.getUser().then(function (u) {
3 | if (u) {
4 | angular.bootstrap(document, ['app']);
5 | } else {
6 | auth.redirectToSignIn();
7 | }
8 | }).catch(function (e) {
9 | console.log("==== user error ==== ");
10 | console.log(e);
11 | });
12 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/layout.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").controller("'LayoutController", LayoutController);
3 |
4 | function LayoutController() {
5 | var vm = this;
6 | }
7 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/layout.template.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/profile.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").directive("profile", profileDirective);
3 |
4 | function profileDirective() {
5 | return {
6 | restrict: "E",
7 | templateUrl: "app/core/profile.template.html"
8 | };
9 | }
10 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/profile.template.html:
--------------------------------------------------------------------------------
1 |
2 |

3 |
4 |
5 | Welcome,
6 |
John Doe
7 |
8 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/sidebar-footer.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").directive("sidebarFooter", sidebarFooterDirective);
3 |
4 | function sidebarFooterDirective() {
5 | return {
6 | restrict: "E",
7 | templateUrl: "app/core/sidebar-footer.template.html"
8 | };
9 | }
10 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/sidebar-footer.template.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/sidebar-menu.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").directive("sidebarMenu", sidebarMenuDirective);
3 |
4 | function sidebarMenuDirective() {
5 | return {
6 | restrict: "E",
7 | templateUrl: "app/core/sidebar-menu.template.html",
8 | controller: "SidebarMenuController",
9 | controllerAs: "vm"
10 | };
11 | }
12 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/sidebar-menu.service.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").service("sidebarMenuService", SidebarMenuService);
3 |
4 | function SidebarMenuService($q) {
5 | var svc = this;
6 |
7 | svc.getSections = getSections;
8 |
9 | function getSections() {
10 | return $q.resolve([
11 | {
12 | text: "General",
13 | items: [
14 | {
15 | text: "Home",
16 | icon: "home",
17 | items: [
18 | {
19 | text: "Dashboard",
20 | state: "home.dashboard"
21 | }
22 | ]
23 | },
24 | {
25 | text: "Mantenimientos",
26 | icon: "edit",
27 | items: [
28 | {
29 | text: "Productos",
30 | state: "mantenimientos.productos"
31 | }
32 | ]
33 | }
34 | ]
35 | }
36 | ]);
37 | }
38 | }
39 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/sidebar-menu.template.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/sidebar.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").directive("sidebar", sidebarDirective);
3 |
4 | function sidebarDirective() {
5 | return {
6 | restrict: "E",
7 | templateUrl: "app/core/sidebar.template.html"
8 | };
9 | }
10 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/sidebar.template.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/core/top-nav.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").directive("topNav", topNavDirective);
3 |
4 | function topNavDirective() {
5 | return {
6 | restrict: "E",
7 | templateUrl: "app/core/top-nav.template.html"
8 | };
9 | }
10 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/home/dashboard-graph.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").directive("dashboardGraph", dashboardGraphDirective);
3 |
4 | function dashboardGraphDirective() {
5 | return {
6 | restrict: "E",
7 | templateUrl: "app/home/dashboard-graph.template.html"
8 | };
9 | }
10 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/home/dashboard.template.html:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/home/ping.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").directive("ping", PingDirective);
3 |
4 | function PingDirective() {
5 | return {
6 | restrict: "E",
7 | template: "Ping Result
",
8 | controller: PingController,
9 | controllerAs: "vm"
10 | };
11 | }
12 |
13 | function PingController($http, $log) {
14 | var vm = this;
15 |
16 | vm.results = [];
17 |
18 | init();
19 |
20 | function init() {
21 | loadPingResults();
22 | }
23 |
24 | function loadPingResults() {
25 | var methods = ["GET", "POST", "PUT", "PATCH", "DELETE"];
26 | for (var i = 0; i < methods.length; i++) {
27 | var method = methods[i];
28 | $http({
29 | method: method,
30 | url: 'http://localhost:51902/api/ping',
31 | headers: { 'Authorization': 'Bearer ' + auth.currentUser().access_token },
32 | }).then(function (r) {
33 | vm.results.push(r.data);
34 | }).catch(function (e) {
35 | $log.error(e);
36 | });
37 | }
38 | }
39 | }
40 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/home/top-tiles.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").directive("topTiles", topTilesDirective);
3 |
4 | function topTilesDirective() {
5 | return {
6 | restrict: "E",
7 | templateUrl: "app/home/top-tiles.template.html"
8 | };
9 | }
10 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/home/top-tiles.template.html:
--------------------------------------------------------------------------------
1 |
2 |
Total Users
3 |
2500
4 |
4% From last Week
5 |
6 |
7 |
Average Time
8 |
123.50
9 |
3% From last Week
10 |
11 |
12 |
Total Males
13 |
2,500
14 |
34% From last Week
15 |
16 |
17 |
Total Females
18 |
4,567
19 |
12% From last Week
20 |
21 |
22 |
Total Collections
23 |
2,315
24 |
34% From last Week
25 |
26 |
27 |
Total Connections
28 |
7,325
29 |
34% From last Week
30 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/mantenimientos/productos-crear.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 |
3 | angular.module("app").controller("ProductosCrearController", ProductosCrearController);
4 |
5 | function ProductosCrearController(productosServicio) {
6 |
7 | var vm = this;
8 |
9 | init();
10 |
11 | function init() {
12 | }
13 |
14 | }
15 |
16 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/mantenimientos/productos-crear.template.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/mantenimientos/productos-listado.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 |
3 | angular.module("app").controller("ProductosListadoController", ProductosListadoController);
4 |
5 | function ProductosListadoController(productosServicio) {
6 |
7 | var vm = this;
8 |
9 | vm.pagina = 1;
10 | vm.productos = [];
11 |
12 | init();
13 |
14 | function init() {
15 | obtenerProductos();
16 | }
17 |
18 | function obtenerProductos() {
19 | productosServicio.obtenerTodos(vm.pagina).then(cargarProductos);
20 | }
21 |
22 | function cargarProductos(productos) {
23 | console.log(productos);
24 | vm.productos = productos;
25 | }
26 | }
27 |
28 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/mantenimientos/productos-listado.template.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Productos mantenimiento
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Listado de productos
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | | Código |
29 | Nombre |
30 | Existencia |
31 | Precio Base |
32 | |
33 |
34 |
35 |
36 |
37 |
38 | |
39 | |
40 | |
41 | |
42 | |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/mantenimientos/productos.servicio.js:
--------------------------------------------------------------------------------
1 | (function () {
2 |
3 | angular.module("app").service("productosServicio", ProductosServicio);
4 |
5 | function ProductosServicio($http) {
6 |
7 | var api = "http://localhost:51902/api";
8 | var elementosPorPagina = 20;
9 |
10 | var svc = this;
11 |
12 | svc.obtenerTodos = obtenerTodos;
13 |
14 | function obtenerTodos(pagina) {
15 |
16 | if (!pagina || pagina < 1) {
17 | pagina = 1;
18 | }
19 |
20 | var url = api + "/productos?pagina=" + pagina + "&elementos=" + elementosPorPagina;
21 | return $http.get(url, { headers : getAuthorizationHeader() }).then(function (result) { return result.data });
22 | }
23 |
24 | function getAuthorizationHeader() {
25 | // obtiene el header de HTTP necesario para enviar el token
26 | // de autenticación para la api.
27 | //
28 | // auth es una variable global, definida por /app/auth.js
29 | return { 'Authorization': 'Bearer ' + auth.currentUser().access_token };
30 | }
31 |
32 | }
33 |
34 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/app/routes.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | angular.module("app").config(configRoutes);
3 |
4 | function configRoutes($urlRouterProvider, $stateProvider) {
5 | $urlRouterProvider
6 | .when("", "/home/dashboard")
7 | .when("/", "/home/dashboard");
8 |
9 | $stateProvider
10 | .state("default", {
11 | abstract: true,
12 | url: "",
13 | controller: "LayoutController",
14 | controllerAs: "vm",
15 | views: {
16 | layout: {
17 | templateUrl: "app/core/layout.template.html"
18 | }
19 | }
20 | })
21 | .state("home", {
22 | abstract: true,
23 | url: "/home",
24 | template: "",
25 | parent: "default"
26 | })
27 | .state("home.dashboard", {
28 | url: "/dashboard",
29 | templateUrl: "app/home/dashboard.template.html"
30 | })
31 | .state("mantenimientos", {
32 | abstract: true,
33 | url: "/mantenimientos",
34 | template: "",
35 | parent: "default"
36 | })
37 | .state("mantenimientos.productos", {
38 | url: "/productos",
39 | controller: "ProductosListadoController",
40 | controllerAs: "vm",
41 | templateUrl: "app/mantenimientos/productos-listado.template.html"
42 | })
43 | .state("mantenimientos.productos-crear", {
44 | url: "/productos/crear",
45 | controller: "ProductosCrearController",
46 | controllerAs: "vm",
47 | templateUrl: "app/mantenimientos/productos-crear.template.html"
48 | });
49 | }
50 | })();
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/check_session.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | RP Check Session IFrame
5 |
6 |
7 |
8 |
9 |
60 |
61 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/favicon.ico
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/FontAwesome.otf
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/fontawesome-webfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/fontawesome-webfont.woff2
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/images/img.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/app/images/img.jpg
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Cargando...
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Cargando...
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/signedout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/signin-renew.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/specs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | specs
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/app/specs.js:
--------------------------------------------------------------------------------
1 | function successPromise(result) {
2 | return function () {
3 | return {
4 | then: function (callback) {
5 | return callback(result);
6 | }
7 | };
8 | };
9 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/App_Data/idsrv3test.pfx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/auth/App_Data/idsrv3test.pfx
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Configuration/Certificate.cs:
--------------------------------------------------------------------------------
1 | using System.Security.Cryptography.X509Certificates;
2 | using System.Web.Hosting;
3 |
4 | namespace Auth.Configuration
5 | {
6 | public class Certificate
7 | {
8 | public static X509Certificate2 Load()
9 | {
10 | var certPath = HostingEnvironment.MapPath("~/App_Data/idsrv3test.pfx");
11 | return new X509Certificate2(certPath, "idsrv3test");
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Configuration/Clients.cs:
--------------------------------------------------------------------------------
1 | using IdentityServer3.Core.Models;
2 | using System.Collections.Generic;
3 |
4 | namespace Auth.Configuration
5 | {
6 | public class Clients
7 | {
8 | public static List Get()
9 | {
10 | return new List
11 | {
12 | new Client
13 | {
14 | Enabled = true,
15 | ClientName = "Single Page Application",
16 | ClientId = "spa",
17 | Flow = Flows.Implicit,
18 | RedirectUris = new List
19 | {
20 | "http://localhost:51900/signin.html",
21 | "http://localhost:51900/signin-renew.html"
22 | },
23 | PostLogoutRedirectUris = new List
24 | {
25 | "http://localhost:51900/signedout.html"
26 | },
27 | AllowedCorsOrigins = new List
28 | {
29 | "http://localhost:51900"
30 | },
31 | AllowAccessToAllScopes = true,
32 | RequireConsent = false
33 | }
34 | };
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Configuration/Scopes.cs:
--------------------------------------------------------------------------------
1 | using IdentityServer3.Core.Models;
2 | using System.Collections.Generic;
3 |
4 | namespace Auth.Configuration
5 | {
6 | public class Scopes
7 | {
8 | public static List Get()
9 | {
10 | return new List
11 | {
12 | StandardScopes.OpenId,
13 | StandardScopes.Profile,
14 | StandardScopes.Email,
15 | new Scope
16 | {
17 | Name = "api",
18 | DisplayName = "Access to API",
19 | Description = "This will grant you access to the API",
20 | ScopeSecrets = new List
21 | {
22 | new Secret("59D8076E-A7B4-4348-9B02-F358A869E3B8".Sha256())
23 | },
24 | Type = ScopeType.Resource,
25 | IncludeAllClaimsForUser = true
26 | }
27 | };
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Configuration/Users.cs:
--------------------------------------------------------------------------------
1 | using IdentityServer3.Core;
2 | using IdentityServer3.Core.Services.InMemory;
3 | using System.Collections.Generic;
4 | using System.Security.Claims;
5 |
6 | namespace Auth.Configuration
7 | {
8 | public class Users
9 | {
10 | public static List Get()
11 | {
12 | return new List
13 | {
14 | new InMemoryUser
15 | {
16 | Username = "bob",
17 | Password = "secret",
18 | Subject = "1",
19 |
20 | Claims = new[]
21 | {
22 | new Claim(Constants.ClaimTypes.GivenName, "Bob"),
23 | new Claim(Constants.ClaimTypes.FamilyName, "Smith"),
24 | new Claim(Constants.ClaimTypes.Email, "bob.smith@email.com")
25 | }
26 | }
27 | };
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("auth")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("auth")]
12 | [assembly: AssemblyCopyright("Copyright © 2016")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("3a885e15-7b86-4142-977a-cecb07b93678")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Revision and Build Numbers
32 | // by using the '*' as shown below:
33 | [assembly: AssemblyVersion("1.0.0.0")]
34 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Startup.cs:
--------------------------------------------------------------------------------
1 | using Auth.Configuration;
2 | using IdentityServer3.Core.Configuration;
3 | using Owin;
4 |
5 | namespace Auth
6 | {
7 | public class Startup
8 | {
9 | public void Configuration(IAppBuilder app)
10 | {
11 | var options = new IdentityServerOptions
12 | {
13 | SiteName = "Application Signin Server",
14 | Factory = new IdentityServerServiceFactory()
15 | .UseInMemoryClients(Clients.Get())
16 | .UseInMemoryScopes(Scopes.Get())
17 | .UseInMemoryUsers(Users.Get()),
18 | SigningCertificate = Certificate.Load(),
19 | RequireSsl = false
20 | };
21 |
22 | app.UseIdentityServer(options);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miguelerm/samples/306fb8dfcb95a49e61be4a23cbf309b52020d183/dotNet/oauth-ng-cs/auth/favicon.ico
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/auth/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/dotNet/oauth-ng-cs/oauth-ng-cs.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "api", "api\api.csproj", "{E98942C9-A3C7-4C6C-BC80-792A59469072}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "auth", "auth\auth.csproj", "{3A885E15-7B86-4142-977A-CECB07B93678}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "app", "app\app.csproj", "{62173C8D-1AE4-4848-9AFA-8707D830A32C}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {E98942C9-A3C7-4C6C-BC80-792A59469072}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {E98942C9-A3C7-4C6C-BC80-792A59469072}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {E98942C9-A3C7-4C6C-BC80-792A59469072}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {E98942C9-A3C7-4C6C-BC80-792A59469072}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {3A885E15-7B86-4142-977A-CECB07B93678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {3A885E15-7B86-4142-977A-CECB07B93678}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {3A885E15-7B86-4142-977A-CECB07B93678}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {3A885E15-7B86-4142-977A-CECB07B93678}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {62173C8D-1AE4-4848-9AFA-8707D830A32C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {62173C8D-1AE4-4848-9AFA-8707D830A32C}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {62173C8D-1AE4-4848-9AFA-8707D830A32C}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {62173C8D-1AE4-4848-9AFA-8707D830A32C}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------