Exercise Files
This commit is contained in:
22
Ch03/03_03_Begin/Website/Extensions/TempDataExtensions.cs
Normal file
22
Ch03/03_03_Begin/Website/Extensions/TempDataExtensions.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace HPlusSports
|
||||
{
|
||||
public static class TempDataExtensions
|
||||
{
|
||||
const string SuccessMessageKey = "SuccessMessage";
|
||||
|
||||
public static string SuccessMessage(this System.Web.Mvc.TempDataDictionary tempData)
|
||||
{
|
||||
return tempData[SuccessMessageKey] as string;
|
||||
}
|
||||
|
||||
public static void SuccessMessage(this System.Web.Mvc.TempDataDictionary tempData, string successMessage)
|
||||
{
|
||||
tempData[SuccessMessageKey] = successMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Ch03/03_03_Begin/Website/Extensions/UrlHelperExtensions.cs
Normal file
21
Ch03/03_03_Begin/Website/Extensions/UrlHelperExtensions.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using HPlusSports.Models;
|
||||
|
||||
namespace HPlusSports
|
||||
{
|
||||
public static class UrlHelperExtensions
|
||||
{
|
||||
public static string Product(this System.Web.Mvc.UrlHelper urlHelper, Product product)
|
||||
{
|
||||
return Product(urlHelper, product?.SKU);
|
||||
}
|
||||
|
||||
public static string Product(this System.Web.Mvc.UrlHelper urlHelper, string sku)
|
||||
{
|
||||
return urlHelper.Action("Product", "Products", new { id = sku });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user