Files
yavsc/web/CatExts/WebCatalogExtensions.cs
Paul Schneider 3c6c3f19aa Refactoring: moving
the Catalog manager and model into the Yavsc.Model.FrontOffice 
namespace
* Web.config:
* Catalog.xml:
* MyClass.cs:
* Note.cs:
* Euro.cs:
* Unit.cs:
* Text.cs:
* Link.cs:
* Price.cs:
* Label.cs:
* Brand.cs:
* Scalar.cs:
* Option.cs:
* Period.cs:
* YavscModel.csproj:
* Catalog.cs:
* Service.cs:
* Product.cs:
* YavscClient.csproj:
* CatalogManager.cs:
* Currency.cs:
* CheckBox.cs:
* SaleForm.cs:
* FormInput.cs:
* CatalogProvider.cs:
* TextInput.cs:
* SelectItem.cs:
* SalesCatalog.csproj:
* FilesInput.cs:
* FormElement.cs:
* SelectInput.cs:
* IValueProvider.cs:
* StockStatus.cs:
* RadioButton.cs:
* Commande.cs:
* ProductImage.cs:
* WebCatalogExtensions.cs:
* TemplateException.cs:
* ProductCategory.cs:
* PhysicalProduct.cs:
* Note.cs:
* Link.cs:
* Text.cs:
* Euro.cs:
* Unit.cs:
* WorkFlowManager.cs:
* Brand.cs:
* Label.cs:
* Price.cs:
* Scalar.cs:
* FrontOfficeController.cs:
* Period.cs:
* Option.cs:
* Product.cs:
* Service.cs:
* Catalog.cs:
* SaleForm.cs:
* Currency.cs:
* CheckBox.cs:
* TextInput.cs:
* FrontOfficeApiController.cs:
* FormInput.cs:
* SelectItem.cs:
* FilesInput.cs:
* XmlCatalog.cs:
* FormElement.cs:
* SelectInput.cs:
* RadioButton.cs:
* StockStatus.cs:
* ProductImage.cs:
* CatalogHelper.cs:
* CatalogManager.cs:
* CatalogProvider.cs:
* ProductCategory.cs:
* PhysicalProduct.cs:
* XmlCatalogProvider.cs:
* CatalogProviderConfigurationElement.cs:
* CatalogProvidersConfigurationSection.cs:
* CatalogProvidersConfigurationCollection.cs:
* CatalogProviderConfigurationElement.cs:
* CatalogProvidersConfigurationSection.cs:
* CatalogProvidersConfigurationCollection.cs: 
* CatalogHelper.cs:
2015-01-28 15:04:07 +01:00

94 lines
2.9 KiB
C#

using System;
using System.Web;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Mvc.Html;
using Yavsc.Model.FrontOffice;
namespace Yavsc.CatExts
{
/// <summary>
/// Web catalog extensions.
/// </summary>
public static class WebCatalogExtensions
{
/// <summary>
/// Commands the form.
/// </summary>
/// <returns>The form.</returns>
/// <param name="helper">Helper.</param>
/// <param name="pos">Position.</param>
/// <param name="atc">Atc.</param>
public static string CommandForm(this HtmlHelper<PhysicalProduct> helper, Product pos,string atc="Add to backet") {
StringBuilder sb = new StringBuilder ();
sb.Append (helper.ValidationSummary ());
TagBuilder ft = new TagBuilder ("form");
ft.Attributes.Add("action","/FrontOffice/Command");
ft.Attributes.Add("method","post");
ft.Attributes.Add("enctype","multipart/form-data");
TagBuilder fieldset = new TagBuilder ("fieldset");
TagBuilder legend = new TagBuilder ("legend");
legend.SetInnerText (pos.Name);
TagBuilder para = new TagBuilder ("p");
StringBuilder sbfc = new StringBuilder ();
if (pos.CommandForm != null)
foreach (FormElement e in pos.CommandForm.Items) {
sbfc.Append (e.ToHtml ());
sbfc.Append ("<br/>\n");
}
sbfc.Append (
string.Format(
"<input type=\"submit\" value=\"{0}\"/><br/>\n",
atc
));
sbfc.Append (helper.Hidden ("ref", pos.Reference));
para.InnerHtml = sbfc.ToString ();
fieldset.InnerHtml = legend.ToString ()+"\n"+para.ToString ();
ft.InnerHtml = fieldset.ToString ();
sb.Append (ft.ToString ());
return sb.ToString ();
}
/// <summary>
/// Commands the form.
/// </summary>
/// <returns>The form.</returns>
/// <param name="helper">Helper.</param>
/// <param name="pos">Position.</param>
/// <param name="atc">Atc.</param>
public static string CommandForm(this HtmlHelper<Service> helper, Product pos,string atc="Add to backet") {
StringBuilder sb = new StringBuilder ();
sb.Append (helper.ValidationSummary ());
TagBuilder ft = new TagBuilder ("form");
ft.Attributes.Add("action","/FrontOffice/Command");
ft.Attributes.Add("method","post");
ft.Attributes.Add("enctype","multipart/form-data");
TagBuilder fieldset = new TagBuilder ("fieldset");
TagBuilder legend = new TagBuilder ("legend");
legend.SetInnerText (pos.Name);
TagBuilder para = new TagBuilder ("p");
StringBuilder sbfc = new StringBuilder ();
if (pos.CommandForm != null)
foreach (FormElement e in pos.CommandForm.Items) {
sbfc.Append (e.ToHtml ());
sbfc.Append ("<br/>\n");
}
sbfc.Append (
string.Format(
"<input type=\"submit\" value=\"{0}\"/><br/>\n",atc));
sbfc.Append (helper.Hidden ("ref", pos.Reference));
para.InnerHtml = sbfc.ToString ();
fieldset.InnerHtml = legend.ToString ()+"\n"+para.ToString ();
ft.InnerHtml = fieldset.ToString ();
sb.Append (ft.ToString ());
return sb.ToString ();
}
}
}