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" />
public class AutoMapperConfig
{
public static void RegisterMappings()
{
Mapper.Initialize(c =>
{
c.AddProfile<DomainToViewModelMappingProfile>();
c.AddProfile<ViewModelToDomainMappingProfile>();
});
}
@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();
}
@Pierry
Pierry / IRepositoryBase.cs
Created November 18, 2014 18:29
IRepositoryBase
public interface IRepositoryBase<TEntity> where TEntity : class
{
TEntity Add(TEntity item);
TEntity GetById(int id);
IEnumerable<TEntity> Get();
bool Update(TEntity item);
int Count();
void Dispose();
}
@Pierry
Pierry / AutoMapperConfig.cs
Created October 22, 2014 11:17
AutoMapper
public class AutoMapperConfig
{
public static void RegisterMappings()
{
Mapper.Initialize(c =>
{
c.AddProfile<DomainToViewModelMappingProfile>();
c.AddProfile<ViewModelToDomainMappingProfile>();
});
}
@bradwilson
bradwilson / gist:2417226
Created April 18, 2012 22:55
Ninject dependency resolver for Web API
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Web.Http.Dependencies;
using Ninject;
using Ninject.Syntax;
public class NinjectDependencyScope : IDependencyScope
{
private IResolutionRoot resolver;