Format:
Recent snippets for: couellet
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"; }); }
18 Views
no comments
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; } }
35 Views
no comments
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,
31 Views
no comments
$.msgBar({
type: 'error',
text: 'Message',
sticky: true
}).appendTo($(container));
58 Views
no comments
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 {
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);
63 Views
no comments
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))
67 Views
no comments
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");
47 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
