Skip to content

Instantly share code, notes, and snippets.

View lucasselliach's full-sized avatar
🏠
Working from home

Lucas Selliach lucasselliach

🏠
Working from home
View GitHub Profile
public class ExportToExcelService
{
public void ToExcel(HttpResponseBase Response, object clientsList)
{
var grid = new System.Web.UI.WebControls.GridView();
grid.DataSource = clientsList;
grid.DataBind();
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=FileName.xls");
Response.ContentType = "application/excel";
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
@lucasselliach
lucasselliach / README.md
Created March 4, 2016 17:32 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

public class AssertionConcern
{
protected AssertionConcern()
{
}
public static void AssertArgumentEquals(object object1, object object2, string message)
{
if (!object1.Equals(object2))
{
public class AutoMapperConfig
{
public static void RegisterMappings()
{
Mapper.Initialize(c =>
{
c.AddProfile<DomainToViewModelMappingProfile>();
c.AddProfile<ViewModelToDomainMappingProfile>();
});
}
@lucasselliach
lucasselliach / ConnectionStrings
Last active September 8, 2015 19:09
Connection strings to use with Entity Framework
<connectionStrings>
<add name="AppContext" connectionString="data source=(LocalDB)\v11.0;attachdbfilename=C:\Users\Pierry\Documents\Repositorios\ddd-ef-di-api-mvc\SpaUserControl.Data\MyDB.mdf;Database=MyDb;Trusted_Connection=Yes;" providerName="System.Data.SqlClient" />
</connectionStrings>
@lucasselliach
lucasselliach / CertificadoDigital
Created August 26, 2015 13:48
Buscar Certificado digital no computador e realizar a assinatura para ativação do dispositivo SAT
public static class CertificadoDigital
{
public static X509Certificate2 BuscaCertificado()
{
var x509Cert = new X509Certificate2();
try
{
var store = new X509Store(StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
@lucasselliach
lucasselliach / XmlSerializer.cs
Last active September 9, 2015 14:12 — forked from Pierry/gist:2d266a9b204fff3a999c
XmlSerializer to NFE
public XmlDocument CriarArquivoEnvio()
{
var consultaServico = new StatusServicoEnvio("1.00", 2);
var serializer = new XmlSerializer(typeof (StatusServicoEnvio));
using (var stream = new StreamWriter(PathEnvio))
{
serializer.Serialize(stream, consultaServico);
}
var doc = new XmlDocument();
doc.Load(PathEnvio);
@lucasselliach
lucasselliach / IServiceBase.cs
Created April 9, 2015 20:20
All Servise Base
public interface IServiceBase<TEntity> where TEntity : class
{
void Add(TEntity obj);
TEntity GetById(int id);
IEnumerable<TEntity> GetAll();
void Update(TEntity obj);
void Remove(TEntity obj);
void Dispose();
}
@lucasselliach
lucasselliach / IRepositoryBase.cs
Last active August 29, 2015 14:18
All RepositoryBase
public interface IRepositoryBase<TEntity> where TEntity : class
{
void Add(TEntity obj);
TEntity GetById(int id);
IEnumerable<TEntity> GetAll();
void Update(TEntity obj);
void Remove(TEntity obj);
void Dispose();
}