Skip to content

Commit

Permalink
Final Review with Derick Bailey for Knockout Production
Browse files Browse the repository at this point in the history
  • Loading branch information
subsonic committed Aug 3, 2012
1 parent 040dbdb commit 65da5f1
Show file tree
Hide file tree
Showing 418 changed files with 73,522 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MvcMusicStore.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcMusicStore", "MvcMusicStore\MvcMusicStore.csproj", "{32DCD27D-A84C-4250-B657-408B3620A9AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{32DCD27D-A84C-4250-B657-408B3620A9AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32DCD27D-A84C-4250-B657-408B3620A9AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32DCD27D-A84C-4250-B657-408B3620A9AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32DCD27D-A84C-4250-B657-408B3620A9AC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added MvcMusicStore.suo
Binary file not shown.
Binary file added MvcMusicStore.v11.suo
Binary file not shown.
4 changes: 4 additions & 0 deletions MvcMusicStore/App_Code/Assets.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@helper AlbumArt(MvcMusicStore.Models.Album album, string size = "260"){
//your CDN url goes here
<img src="/assets/images/album_art/@album.AlbumArtUrl" alt="@album.Title" width="@size"/>
}
92 changes: 92 additions & 0 deletions MvcMusicStore/App_Code/Forms.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
@helper ValidationMessage(string name){
<span class="field-validation-valid" data-valmsg-for="@name" data-valmsg-replace="true"></span>
}
@helper TextBox(string name, object value = null, int? size =null) {
var val = value ?? "";
var _size = size ?? 20;
<p>
<label>@name</label>
<input type="text" name="@name" id="@name" value="@val" size = '@_size'/>
</p>
}
@helper TextBoxDate(string name, object value = null) {
var val = value ?? "";
<p>
<label>@name</label>
<input type="text" name="@name" id="@name" value="@val" class="datepicker"/>
</p>
}
@helper TextBoxRequired(string name, object value = null, int? size=null, string requiredMessage = "Required") {
var val = value ?? "";
var _size = size ?? 20;
<p>
<label>@name *</label>
<input type="text" name="@name" id="@name" value="@val" data-val="true" data-val-required="@requiredMessage" size = '@_size'/>
@ValidationMessage(name)
</p>

}
@helper TextBoxNumber(string name, object value = null, string numberMessage = "Should be a number") {
var val = value ?? "";
<p>
<label>@name *</label>
<input type="text" name="@name" id="@name" value="@val" data-val="true"
data-val-number="@numberMessage" />
@ValidationMessage(name)
</p>

}
@helper TextArea(string name, string attributes = "", object value = null) {
var val = value ?? "";
<p>
<label>@name</label>
<textarea name="@name" id="@name" @attributes >@val</textarea>
</p>
}
@helper Submit(string value="Save"){
<p>
<button type="submit" class="button positive">
<img src="/public/stylesheets/plugins/buttons/icons/tick.png" alt=""/>@value
</button>
</p>
<div class="clear"></div>
}
@helper HiddenID(object id){
<input type="hidden" name="ID" id="ID" value="@id" />
}

@helper DeleteButton(string actionUrl,int itemId, bool iconOnly=false) {
<form class="delForm" action="@actionUrl" method="post" style = "display:inline">
<input type="hidden" name="id" value="@itemId" />
<button type="submit" class="btn btn-danger">
<i class="icon icon-remove icon-white"></i>
@if(!iconOnly){
<span>Delete</span>
}
</button>
</form>
}

@helper SubmitLink(string text, string icon = "") {
<button type="submit" class="link">
<i class="icon @icon"></i>
@text
</button>
}

@helper DeleteConfirmScript(){
<script type="text/javascript">
$().ready(function () {
$(".delForm").submit(function () {
return confirm("Delete this record? Are you sure?");
});
});
</script>
}

@helper EditButton(string url){
<a href="@url" class="btn btn-info">
<i class="icon icon-edit icon-white"></i>
Edit
</a>
}
19 changes: 19 additions & 0 deletions MvcMusicStore/App_Code/Notifier.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@helper Script(dynamic tempData){
<div class="container">
<div id="notifier" class="row span8"></div>
</div>

if (tempData["message"] != null) {
<script type="text/javascript">
notifier.success('@tempData["message"]');
</script>
}else if (tempData["alert"] != null) {
<script type="text/javascript">
notifier.error('@tempData["alert"]');
</script>
}else if (tempData["notice"] != null) {
<script type="text/javascript">
notifier.warn('@tempData["notice"]');
</script>
}
}
27 changes: 27 additions & 0 deletions MvcMusicStore/App_Code/OrderHelper.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@helper LinksForStatus(MvcMusicStore.Models.Order order){
if(order.Status == "paid"){
<form id="statusForm" action="/orders/refund" method="post" style="display:inline">
<input type="hidden" name="id" value="@order.OrderId" />
<li>@Forms.SubmitLink("Refund", "icon-repeat")</li>
</form>
<form id="statusForm" action="/orders/ship" method="post" style="display:inline">
<input type="hidden" name="id" value="@order.OrderId" />
<li>@Forms.SubmitLink("Set As Shipped", "icon-plane")</li>
</form>
}
else if (order.Status == "refunded")
{
<form id="statusForm" action="/orders/void" method="post" style="display:inline">
<input type="hidden" name="id" value="@order.OrderId" />
<li>@Forms.SubmitLink("Void", "icon-ban-circle")</li>
</form>
}
else if (order.Status == "shipped")
{
<form id="statusForm" action="/orders/refund" method="post" style="display:inline">
<input type="hidden" name="id" value="@order.OrderId" />
<li>@Forms.SubmitLink("Refund", "icon-repeat")</li>
</form>
}

}
Binary file added MvcMusicStore/App_Data/ASPNETDB.MDF
Binary file not shown.
Binary file added MvcMusicStore/App_Data/aspnetdb_log.ldf
Binary file not shown.
83 changes: 83 additions & 0 deletions MvcMusicStore/CodeTemplates/AddController/Controller.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<#@ template language="C#" HostSpecific="True" #>
<#
MvcTextTemplateHost mvcHost = (MvcTextTemplateHost)(Host);

string EntitySet = mvcHost.ControllerName.Replace("Controller","");
string ModelName = EntitySet.TrimEnd(new char[]{'s'});
#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using System.Data.Entity;
using MvcMusicStore.Models;

namespace <#= mvcHost.Namespace #>
{
public class <#= mvcHost.ControllerName #> : DbController
{

public ActionResult Index()
{
return View(db.<#=EntitySet#>.ToList());
}

<#
if(mvcHost.AddActionMethods) {
#>

public ActionResult Details(int id)
{
return View(db.<#=EntitySet#>.Find(id));
}

public ActionResult Create()
{
return View();
}

[HttpPost]
public ActionResult Create(<#=ModelName#> item)
{
if (ModelState.IsValid)
{
db.<#=EntitySet#>.Add(item);
return RedirectToAction("Index");
}
else
{
return View();
}
}

public ActionResult Edit(int id)
{
return View(db.<#=EntitySet#>.Find(id));
}


[HttpPost]
public ActionResult Edit(<#=ModelName#> item)
{
if (ModelState.IsValid)
{
db.Entry(item).State = EntityState.Modified;
}

return View(item);
}

[HttpPost]
public ActionResult Delete(int id)
{
var item = db.<#=EntitySet#>.Find(id);
db.<#=EntitySet#>.Remove(item);
return RedirectToAction("Index");
}
<#
}
#>
}
}
Loading

0 comments on commit 65da5f1

Please sign in to comment.