This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TrimmingModelPropertiesBinder : IModelBinder | |
{ | |
private static readonly Type[] SimpleTypes = | |
{ | |
typeof(Enum), | |
typeof(String), | |
typeof(Decimal), | |
typeof(DateTime), | |
typeof(DateTimeOffset), | |
typeof(TimeSpan), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string Parse(this DbEntityValidationException e) | |
{ | |
var builder = new StringBuilder(); | |
foreach (var eve in e.EntityValidationErrors) | |
{ | |
builder.AppendFormat("Entity type: {0} | State: {1}",eve.Entry.Entity.GetType().Name,eve.Entry.State); | |
foreach (var ve in eve.ValidationErrors) | |
builder.AppendFormat("Property name: {0} | Current value: {1} | Error message: {2}", | |
ve.PropertyName, | |
eve.Entry.CurrentValues.GetValue<Object>(ve.PropertyName), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq.Expressions; | |
namespace System.Linq | |
{ | |
public static class QueryableHelper | |
{ | |
public static IQueryable<TEntity> Search<TEntity>(this IQueryable<TEntity> query, string searchValue, params Expression<Func<TEntity, string>>[] propertiesToSearch) | |
{ | |
if (string.IsNullOrEmpty(searchValue)) return query; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
public class Program | |
{ | |
private static string GetDigitoVerificadorIBGE(string codigo) | |
{ | |
var pesos = new[] { 1, 2, 1, 2, 1, 2 }; | |
var codigoStr = codigo.ToString(); | |
var soma = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package meuPacote; | |
import java.util.InputMismatchException; | |
public class ValidaCNPJ { | |
public static boolean isCNPJ(String CNPJ) { | |
// considera-se erro CNPJ's formados por uma sequencia de numeros iguais | |
if (CNPJ.equals("00000000000000") || CNPJ.equals("11111111111111") || | |
CNPJ.equals("22222222222222") || CNPJ.equals("33333333333333") || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package meuPacote; | |
import java.util.InputMismatchException; | |
public class ValidaCPF { | |
public static boolean isCPF(String CPF) { | |
// considera-se erro CPF's formados por uma sequencia de numeros iguais | |
if (CPF.equals("00000000000") || CPF.equals("11111111111") || | |
CPF.equals("22222222222") || CPF.equals("33333333333") || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Configuration; | |
using System.IO; | |
using System.Linq; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Web; | |
using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.Blob; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IQueryable<T> GetAll(params Expression<Func<T, object>>[] includes) | |
{ | |
IQueryable<T> result = Context.Set<T>(); | |
if (includes.Any()) | |
{ | |
foreach (var include in includes) | |
{ | |
result = result.Include(include); | |
} |