Skip to content

Commit

Permalink
Code Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Brind committed Dec 27, 2012
0 parents commit c20c74a
Show file tree
Hide file tree
Showing 53 changed files with 12,199 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
161 changes: 161 additions & 0 deletions .gitignore
@@ -0,0 +1,161 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata

tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
.builds
*.dotCover

## TODO: If you have NuGet Package Restore enabled, uncomment this
#packages/

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf


# Visual Studio profiler
*.psess
*.vsp

# ReSharper is a .NET coding add-in
_ReSharper*

# Installshield output folder
[Ee]xpress

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish

# Others
[Oo]bj
sql
TestResults
*.Cache
ClientBin
stylecop.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML



############
## Windows
############

# Windows image file caches
Thumbs.db

# Folder config file
Desktop.ini


#############
## Python
#############

*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
var
sdist
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg

# Mac crap
.DS_Store
13 changes: 13 additions & 0 deletions App_Code/ChatHub.cs
@@ -0,0 +1,13 @@
using Microsoft.AspNet.SignalR.Hubs;

public class ChatHub : Hub
{
public void Send(string name, string message)
{
Clients.All.broadcastMessage(name, message);
}

public void IsTyping(string name){
Clients.All.sayWhoIsTyping(name);
}
}
24 changes: 24 additions & 0 deletions App_Code/ProductHub.cs
@@ -0,0 +1,24 @@
using Microsoft.AspNet.SignalR.Hubs;
using WebMatrix.Data;

public class ProductHub : Hub
{
public void BuyProduct(int productId) {
using (var db = Database.Open("Northwind")) {
var unitsInStock = db.QueryValue("SELECT UnitsInStock FROM Products WHERE ProductId = @0", productId);
if (unitsInStock > 0) {
db.Execute("UPDATE Products Set UnitsInStock = UnitsInStock - 1 WHERE ProductId = @0", productId);
unitsInStock -= 1;
}
Clients.All.updateAvailableStock(unitsInStock, productId);
}
}

public void ReorderProduct(int quantity, int productId){
using (var db = Database.Open("Northwind")) {
db.Execute("UPDATE Products Set UnitsInStock = UnitsInStock + @0 WHERE ProductId = @1", quantity, productId);
var unitsInStock = db.QueryValue("SELECT UnitsInStock FROM Products WHERE ProductId = @0", productId);
Clients.All.updateAvailableStock(unitsInStock, productId);
}
}
}
5 changes: 5 additions & 0 deletions App_Data/Admin/PackageSources.config
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<sources>
<source url="http://go.microsoft.com/fwlink/?LinkID=226946" displayname="Default" filterpreferred="true" />
<source url="http://go.microsoft.com/fwlink/?LinkID=226948" displayname="Default (All)" filterpreferred="false" />
</sources>
1 change: 1 addition & 0 deletions App_Data/Admin/Password.config
@@ -0,0 +1 @@
AKBet36DFtlgPrWxiCiZ3PY+ammHL5eX+RGh8MCjYuNayZ2oXKw4Sut6l+dvWvEBaA==
Binary file added App_Data/Northwind.sdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
49 changes: 49 additions & 0 deletions Chat.cshtml
@@ -0,0 +1,49 @@
@{

}

<div class="container">
<div id="isTyping">&nbsp;</div>
<input type="text" id="message" />
<input type="button" id="sendmessage" value="Send" />
<input type="hidden" id="displayname" />
<ul id="discussion"></ul>
</div>

@section script{
<script type="text/javascript">
$(function () {
var chat = $.connection.chatHub;
chat.client.broadcastMessage = function (name, message) {
$('#discussion').append('<li><strong>' + name
+ '</strong>:&nbsp;&nbsp;' + message + '</li>');
};
chat.client.sayWhoIsTyping = function (name) {
$('#isTyping').html('<em>' + name + ' is typing</em>');
setTimeout(function () {
$('#isTyping').html('&nbsp;');
}, 3000);
};
$('#displayname').val(prompt('Enter your name:', ''));
$('#message').focus();
$.connection.hub.start().done(function () {
$('#sendmessage').click(function () {
var encodedName = $('<div />').text($('#displayname').val()).html();
var encodedMsg = $('<div />').text($('#message').val()).html();
chat.server.send(encodedName, encodedMsg);
$('#message').val('').focus();
});
$('#message').keypress(function () {
var encodedName = $('<div />').text($('#displayname').val()).html();
chat.server.isTyping(encodedName);
});
});
});
</script>
}
9 changes: 9 additions & 0 deletions Default.cshtml
@@ -0,0 +1,9 @@
@{
Page.Title = "SignalR Samples";

}

<ul>
<li><a href="~/Chat/">Chat</a></li>
<li><a href="~/Knockout/">Knockout</a></li>
</ul>
7 changes: 7 additions & 0 deletions JsonServices/GetCategories.cshtml
@@ -0,0 +1,7 @@
@{
var db = Database.Open("Northwind");
var sql = "SELECT CategoryId, CategoryName FROM Categories";
var data = db.Query(sql);
Response.ContentType = "application/json";
Json.Write(data, Response.Output);
}
19 changes: 19 additions & 0 deletions JsonServices/GetProductById.cshtml
@@ -0,0 +1,19 @@
@{
if (UrlData[0].IsEmpty() || !UrlData[0].IsInt()) {
Response.SetStatus(HttpStatusCode.BadRequest);
Response.End();
}
var db = Database.Open("Northwind");
var sql = @"SELECT ProductId, ProductName, ContactTitle, ContactName,
CompanyName, QuantityPerUnit, UnitPrice, UnitsInStock, ReorderLevel
FROM Products INNER JOIN Suppliers
ON Products.SupplierID = Suppliers.SupplierID
WHERE ProductId = @0";
var data = db.Query(sql, UrlData[0]);
if(data.Count() == 0){
Response.SetStatus(HttpStatusCode.BadRequest);
Response.End();
}
Response.ContentType = "application/json";
Json.Write(data, Response.Output);
}
15 changes: 15 additions & 0 deletions JsonServices/GetProductsByCategory.cshtml
@@ -0,0 +1,15 @@
@{
if (UrlData[0].IsEmpty() || !UrlData[0].IsInt()) {
Response.SetStatus(HttpStatusCode.BadRequest);
Response.End();
}
var db = Database.Open("Northwind");
var sql = "SELECT ProductId, ProductName From Products Where CategoryId = @0";
var data = db.Query(sql, UrlData[0]);
if(data.Count() == 0){
Response.SetStatus(HttpStatusCode.BadRequest);
Response.End();
}
Response.ContentType = "application/json";
Json.Write(data, Response.Output);
}
3 changes: 3 additions & 0 deletions JsonServices/_PageStart.cshtml
@@ -0,0 +1,3 @@
@{
Layout = null;
}

0 comments on commit c20c74a

Please sign in to comment.