Skip to content

Instantly share code, notes, and snippets.

View nunofilipecosta's full-sized avatar
👨‍💻
coding

Nuno Costa nunofilipecosta

👨‍💻
coding
View GitHub Profile
public class MocheSurfContext : DbContext
{
public MocheSurfContext()
: base("MocheSurfConnectionString")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
@nunofilipecosta
nunofilipecosta / MocheSurfContext.cs
Created March 27, 2013 19:01
Generic Repository
public class MocheSurfContext : GenericRepository.EntityFramework.EntitiesContext
{
public MocheSurfContext()
: base("MocheSurfConnectionString")
{
}
public DbSet<NewsletterSubscription> NewsletterSubscriptions { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
@nunofilipecosta
nunofilipecosta / Build.xml
Created April 7, 2013 18:27
MS Build file template
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\.build</MSBuildCommunityTasksPath>
<SolutionDir>$(MSBuildStartupDirectory)</SolutionDir>
<WebProjectFileName>$(SolutionDir)\src\MocheSurf.FrontEnd\MocheSurf.Frontend.csproj</WebProjectFileName>
<OutputDir>$(SolutionDir)\BuildArtifacts</OutputDir>
</PropertyGroup>
@nunofilipecosta
nunofilipecosta / web.config
Created May 16, 2013 21:18
Log4Net umbraco
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<threshold value="All" />
<file value="\\tomar\Websites\mocherandomgeneration.dev.fullsix.local\private\logs\MocheRandomGeneration.WebApplication.NEW.local.%property{log4net:HostName}.log" type="log4net.Util.PatternString" />"
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="'.'yyyyMMdd'.txt'" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %logger - %message%newline" />
@nunofilipecosta
nunofilipecosta / Global.asax
Created June 5, 2013 14:24
Application_Error
protected void Application_Error(object sender, EventArgs e)
{
var currentException = Server.GetLastError();
if (currentException.GetType() == typeof(HttpException))
{
return;
}
_logger.Fatal("An unhandled exception occurred", currentException);
@nunofilipecosta
nunofilipecosta / file.xml
Created June 17, 2013 22:56
Preventing publishing from Visual Studio to set ACL : *.csproj, *.pubxml, *.proj
<IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
@nunofilipecosta
nunofilipecosta / buil-ci.cmd
Created June 21, 2013 13:55
Command line file for continuous integration
@echo Off
set target=%1
if "%target%" == "" (
set target=build-ci
)
set config=%2
if "%config%" == "" (
set config=Debug
)
@nunofilipecosta
nunofilipecosta / PackageManagerConsole
Last active December 20, 2015 23:19
Re-Install a nuget package
Update-Package [PackageId] -Reinstall
@nunofilipecosta
nunofilipecosta / mobilephonept
Created August 21, 2013 10:32
mobilephonept; email ;
var mobilePhonePt = new Regex(@"^9(1|2|3|6)\d{7}$");
var email = new Regex(@"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}");
@nunofilipecosta
nunofilipecosta / repository.cs
Created September 12, 2013 18:12
Entity Framework Update
public void Update(Entity currentEntity)
{
using(var db = new Context())
{
db.DbSet.Attach(currentEntity);
db.Entry(currentEntity).State = EntityState.Modified;
// V4
////context.ObjectStateManager.ChangeObjectState(currentEntity, EntityState.Modified);
db.SaveChanges();
}