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
gist ws
// En ValuesService.cs
public static readonly string NewsApiUrl = "http://mirepogavilanch2.azurewebsites.net/api/NotiXamarin/";
// En HttpResponse
public class HttpResponse
{
// AssemblyInfo.cs
#if DEBUG
[assembly: Application(Debuggable=true)]
#else
[assembly: Application(Debuggable=false)]
#endif
// tambien deberas traer los siguientes namespaces:
using System;
using System.Linq;
public class LeastParametersConstructorBehavior : IConstructorResolutionBehavior
{
public ConstructorInfo GetConstructor(Type implementationType) => (
from ctor in implementationType.GetConstructors()
orderby ctor.GetParameters().Length ascending
container.Options.ConstructorResolutionBehavior = new LeastParametersConstructorBehavior();
@gavilanch
gavilanch / SimpleInjectorInitializer.cs
Created November 19, 2017 14:09
SimpleInjectorInitializer con el error de ASP.NET MVC 5 accounController corregido
[assembly: WebActivator.PostApplicationStartMethod(typeof(web2.App_Start.SimpleInjectorInitializer), "Initialize")]
namespace web2.App_Start
{
using System.Reflection;
using System.Web.Mvc;
using SimpleInjector;
using SimpleInjector.Integration.Web;
using SimpleInjector.Integration.Web.Mvc;
@gavilanch
gavilanch / Identity_Example.cs
Created April 2, 2018 01:38
Identity example done for blog https:gavilan.blog
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using IdentityDemo.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Authorization;
namespace IdentityDemo.Controllers
{
@gavilanch
gavilanch / selectYWhere.cs
Created October 6, 2018 00:53
Combinando Where y Select
using (var context = new ApplicationDbContext())
{
var fechas = context.Estudiantes.Where(x => x.FechaNacimiento <= DateTime.Now.AddYears(-18)).Select(x => x.FechaNacimiento).ToList();
}
@gavilanch
gavilanch / onConfiguring.cs
Created November 3, 2018 02:38
OnConfiguring - Entity Framework Core - with ConnectionString
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Data Source=(localdb)\\mssqllocaldb;Initial Catalog=EFCore_Mod3_Udemy;Integrated Security=True")
.EnableSensitiveDataLogging(true)
.UseLoggerFactory(new LoggerFactory().AddConsole((category, level) => level == LogLevel.Information && category == DbLoggerCategory.Database.Command.Name, true));
}
USE [master]
GO
/****** Object: Database [ValuesDB] Script Date: 05-May-19 7:19:30 PM ******/
CREATE DATABASE [ValuesDB]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'ValuesDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\ValuesDB.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N'ValuesDB_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\ValuesDB_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AngularTodo</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>