Skip to content

Instantly share code, notes, and snippets.

View gavilanch's full-sized avatar

Felipe Gavilán gavilanch

  • República Dominicana
View GitHub Profile
@gavilanch
gavilanch / Encripta AppSettings.txt
Created February 2, 2017 23:51
Instrucciones para encriptar parte del appSettings
// En la clase
using System.Collections.Specialized;
using System.Configuration;
// En el método
var secureAppSettings = ConfigurationManager.GetSection("secureAppSettings") as NameValueCollection;
var Dato1 = secureAppSettings["Dato1"];
var Dato2 = secureAppSettings["Dato2"];
// En el web.config
using (ApplicationDbContext db = new ApplicationDbContext())
{
var rm = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(db));
var roleId = rm.FindByName("NombreDeLRol").Name;
var usuarios = db.Users.Where(x => x.Roles.Any(y => y.RoleId == roleId)).ToList();
}
public FileResult Descargar()
{
// utilizando la librería DotNetZip
using (ZipFile zip = new ZipFile())
{
// tus archivos (Puedes sacarlos de tu base de datos como arreglos de bytes)
var archivo1 = Server.MapPath("~/archivosDescargar/ejemplo 1.pdf");
var archivo2 = Server.MapPath("~/archivosDescargar/ejemplo 2.pdf");
var archivo3 = Server.MapPath("~/archivosDescargar/gavilanch2.jpg");
@gavilanch
gavilanch / notixamarin1.txt
Created July 29, 2017 17:22
NotiXamarin video 1
// En el Main Activity:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
var newsTitle = FindViewById<TextView>(Resource.Id.newsTitle);
// En mainActivity
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
var newsService = new NewsService();
// En mainActivity
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
var newsService = new NewsService();
// En Main.axml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
// Nota: Debes remover el MainLauncher del MainActivity.cs
// En NewsListRow
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
// En NewsListRow.axml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
// En NewsListActivity.cs
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.NewsList);
var newsListView = FindViewById<ListView>(Resource.Id.newsListView);