CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets for: couellet
C#
protected override void RequestStartup(IKernel container, Nancy.Bootstrapper.IPipelines pipelines)
{
    pipelines.AfterRequest.AddItemToStartOfPipeline(
        x =>
            {
                if (x.Response.ContentType.Contains("text/html"))
                    x.Response.ContentType = "text/html; charset=utf-8";
            });
}
by couellet   February 05, 2012 @ 7:37am
Tags:
18 Views
no comments
 
$.ajax({
  url: url,
  type: 'post'
});
by couellet   November 07, 2011 @ 6:01am
Tags:
45 Views
no comments
 
C#
public static class JsonResultExtensions
   {
       public static T AssertJsonIs<T>(this JsonResult input)
       {
           if (!typeof(T).IsAssignableFrom(input.Data.GetType()))
               throw new AssertionException(string.Format("JsonResult expected type is not matching the actual type{0}Expected type:{1}{0}Actual type:{2}", Environment.NewLine, typeof(T).FullName, input.Data.GetType().FullName));
 
           return (T) input.Data;
       }
   }
by couellet   October 25, 2011 @ 11:13am
Tags:
35 Views
no comments
 
C#
public static IList<SelectListItem> TeeColors(IList<TeeColor> availableColors, TeeColor selectedColor = TeeColor.Green)
        {
            return availableColors.Select(x => ToSelectListItem(x, selectedColor)).ToList();
        }
 
        public static IList<SelectListItem> TeeColors(TeeColor selectedTeeColor = TeeColor.Green)
        {
            var colors = new List<TeeColor>
                             {
                                 TeeColor.Green,
by couellet   October 18, 2011 @ 11:51am
Tags:
31 Views
no comments
 
$.msgBar({
  type: 'error',
  text: 'Message',
  sticky: true
}).appendTo($(container));
by couellet   September 28, 2011 @ 5:38pm
Tags:
58 Views
no comments
 
C#
public ActionResult Login(LoginModel data) {
  if(authenticationService.Login(data.Email, data.Password) {
     notices.Add("LA connexion est correct", NoticeType.Success);
 
     return Json(new {
                       RedirectTo = Url.Action(MVC.Statistics.Index()),
                       Ok = true
                     });
  }
  else {
by couellet   September 28, 2011 @ 5:59am
Tags:
38 Views
no comments
 
$("#login").click(function() {
  $.ajax({
    type: 'post',
    url: '@Url.Action(MVC.Home.Login())',
    success: function(result) {
      if(result.Ok) {
         window.location.href = result.RedirectTo;
      }
      else {
         showErrors(result.Errors);
by couellet   September 28, 2011 @ 5:56am
Tags:
63 Views
no comments
 
C#
public IList<Course> FindCoursesByDistance(decimal latitude, decimal longitude, decimal distance)
        {
            var sqlQuery = session.CreateSQLQuery(
                @"select c.* 
                    from Courses c
                    join FindCoursesByDistance(:Latitude, :Longitude, :Distance) d on d.Id = c.Id");
 
            sqlQuery.AddEntity(typeof (Course))
                .SetDouble("Latitude", Convert.ToDouble(latitude))
                .SetDouble("Longitude", Convert.ToDouble(longitude))
by couellet   July 10, 2010 @ 11:37am
Tags:
67 Views
no comments
 
C#
public static string Scramble(this string input)
        {
            var bytes = Encoding.Default.GetBytes(input);
 
            var encryptor = algorithm.CreateEncryptor();
            var outputBytes = encryptor.TransformFinalBlock(bytes, 0, bytes.Length);
 
            var output = "";
            for (var i = 0; i < outputBytes.Length; i++)
                output += outputBytes[i].ToString("x2");
by couellet   March 10, 2010 @ 10:12am
Tags:
47 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate