Skip to content

Instantly share code, notes, and snippets.

@venblee
venblee / Code First POCO
Created June 19, 2013 09:51
Code First
public class REQ
{
[Key]
public int Id { get; set; }
[DisplayName("REQ Number:"), Required]
public string REQNumber { get; set; }
[DisplayName("Date:"), Required]
@venblee
venblee / Callback
Created June 20, 2013 08:19
Understanding callback functions in Javascript
/
// define our function with the callback argument
function some_function(arg1, arg2, callback) {
// this generates a random number between
// arg1 and arg2
var my_number = Math.ceil(Math.random() *
(arg1 - arg2) + arg2);
// then we're done, so we'll call the callback and
// pass our result
callback(my_number);
@venblee
venblee / General SQL
Created June 20, 2013 12:32
Fix Orpande User Auto
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
use master
if exists (select * from sysobjects where id = object_id(N'dbo.usp_Repair_Orphan_Users_All_DBS') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop PROC dbo.usp_Repair_Orphan_Users_All_DBS
go
Create PROC dbo.usp_Repair_Orphan_Users_All_DBS
@venblee
venblee / new_gist_file
Last active December 18, 2015 17:59
Fix Orpande User
sp_change_users_login 'report'
sp_change_users_login 'auto_fix', #name# -- Name of Ophanend User
@venblee
venblee / OnClick
Created June 21, 2013 07:30
On Container Click Event Binding
var myContainer = $('.centercontainer')
myContainer.on('click' ,'.myclass' , function(e){
e.preventDefault();
// Do your Stuff Here for on click.
});
@venblee
venblee / App_Start
Created June 21, 2013 07:45
Bundeling for Bootsrap
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap*"));
BundleTable.Bundles.Add(new StyleBundle("~/Content/bootstrap").Include("~/Content/bootstrap.css", "~/Content/bootstrap-responsive.css"));
BundleTable.Bundles.Add(new ScriptBundle("~/js").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-migrate-{version}.js",
"~/Scripts/bootstrap.js",
"~/Scripts/jquery.validate.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery.validate.unobtrusive-custom-for-bootstrap.js"
));
@venblee
venblee / SharedView
Created June 21, 2013 07:47
Bootstrap Shared View
@Scripts.Render("~/js")
@* <link rel="shortcut icon" type="image/ico" href="" />*@
<link rel="stylesheet" type="text/css" href="~/Content/bootstrap.css">
<link rel="stylesheet" type="text/css" href="~/Content/dataTables.bootstrap.css">
<link rel="stylesheet" type="text/css" href="~/Content/Select2-3.4.0/select2.css">
@venblee
venblee / Windows Auth
Created June 21, 2013 11:36
Setting Windows Auth in Webconfig
<system.web>
...
<authentication mode="Windows"/>
...
</system.web>
From :
http://msdn.microsoft.com/en-us/library/ff647405.aspx
@venblee
venblee / EF - Linq
Created June 21, 2013 16:03
Select Disctinct using Linq
// Make sure you use DTO and not EF Poco
// Else you will get error
public List<Models.PostalCode> SearchCity(string searchTerm)
{
try
{
using (var db = new PmsContext())
{
var pa = db.PostalCodes.Distinct().Where(x => x.town.Contains(searchTerm)).ToList();
@venblee
venblee / Stored Proc In EF
Created June 21, 2013 16:29
Running Store Proc Code First
{
try
{
using (var db = new PmsContext())
{
var pa = db.PostalCodes.Distinct().Where(x => x.town.Contains(searchTerm)).ToList();
SqlParameter categoryParam = new SqlParameter("@searchTerm", searchTerm);
var cities = db.Database.SqlQuery<List<Models.PostalCode>>("SearchCity @searchTerm", categoryParam).ToList();