Skip to content

Instantly share code, notes, and snippets.

View rippo's full-sized avatar

Richard Wilde rippo

View GitHub Profile
@rippo
rippo / HomeController.cs
Created September 18, 2012 20:09
Simple Data get by multiple columns
var db = Database.Open();
IEnumerable<Login> logins = db.Logins.FindAllByEmailAndPassword(model.Email, model.Password).ToList<Login>();
if (logins.Count() == 1)
{
...
}
//Calling code
[NHibernateActionFilter]
public JsonResult ListContact(long id, [DataSourceRequest] DataSourceRequest request)
{
IQueryable<Contact> contactList;
if (id > 0)
contactList = session.Query<Contact>().Where(y => y.ContactEmailList.Any(x => x.EmailList.Id == id && y.Client.Id == UserHelper.Id));
else
public ContactListDto Filter(IQueryable<Contact> contactList, DataSourceRequest request)
{
..
if (request.Filters.Any())
{
//Single column
var filter = request.Filters[0] as FilterDescriptor;
if (filter != null)
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
namespace Mvc.Cms.Helpers.Localization
{
//http://blog.devdave.com/2011/01/localization-in-aspnet-mvc2-with-data.html
@rippo
rippo / HTML
Created April 26, 2013 17:17
Controllers, directives and templates
<div ng-app="App">
<div ng-controller="AppCtrl">
<products></products>
</div>
</div>
@rippo
rippo / Action result
Last active October 4, 2019 02:18
To show how you could test a NHibernate session.Query<T> on a controller
[NHibernateActionFilter]
public class MemberController
private readonly IDbService db;
public MemberController(IDbService db)
{
this.db = db;
}
@rippo
rippo / BaseTestClass
Created November 7, 2013 15:29
Ugly hack to try and stop KeepAliveFailure exceptions
public class BaseClass
{
public SessionConfiguration sessionConfiguration;
public static string Host = "http://localhost";
public static string PhantomPath;
public static int Port = 53222;
public BaseClass()
{
PhantomPath = ConfigurationManager.AppSettings[Environment.MachineName + "-BinPhysicalPath"];
@rippo
rippo / Helper
Last active August 29, 2015 14:07
Bootstrap validation errors
public static MvcHtmlString BootStrapValidationSummary(this HtmlHelper helper)
{
if (helper.ViewData.ModelState.Keys.Any(k => helper.ViewData.ModelState[k].Errors.Any()))
{
return MvcHtmlString.Create("<div class='alert alert-danger'>"
+ "<button class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>"
+ helper.ValidationSummary(false, "Please check the following:")
+ "</div>");
}
return null;
@rippo
rippo / JSX file
Created March 24, 2015 17:48
React show list from a AJAX call
var MachineInfo = React.createClass({
getInitialState: function() {
return {
data: []
};
},
componentDidMount: function() {
$.get(this.props.source, function(result) {
var MachineInfo = React.createClass({
getInitialState: function() {
return {
data: []
};
},
componentDidMount: function() {
$.get(this.props.source, function(result) {