<%--
Name:
Author:
Description:
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>
<%@ Property Name="SampleStringProperty" Type="System.String" Default="SomeValue" Optional="True" Category="Strings" Description="This is a sample string property." %>
<%@ Property Name="SampleBooleanProperty" Type="System.Boolean" Default="True" Optional="False" Category="Booleans" Description="This is a sample boolean property." %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="System.Data" %>
<%@ Property Name="nameSpace" Type="String" Default="Eatery" Optional="False" Category="" Description="" OnChanged="" Editor="" EditorBase="" Serializer="" %>
<%@ Property Name="index" Type="System.int32" Default="0" Optional="False" Category="" Description="" OnChanged="" Editor="" EditorBase="" Serializer="" %>
<%@ Property Name="db" Type="SchemaExplorer.DatabaseSchema" Default="" Optional="False" Category="Context" Description="???" OnChanged="" Editor="" EditorBase="" Serializer="" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.IO" %>
using System;
using System.Data.Common;
using System.Collections.Generic;
using System.Text;
using Model;
using <%=nameSpace %>DAL;
namespace <%=nameSpace %>BLL
{
public class <%=GetClassName() %>BLL
{
private <%=GetClassName() %>DAL <%=GetObjectName() %>DAL = new <%=GetClassName() %>DAL();
public int Add(<%=GetClassName() %> <%=GetObjectName() %>)
{
return <%=GetObjectName() %>DAL.Add(<%=GetObjectName() %>);
}
public int AddReturn<%=StringUtil.ToPascalCase(db.Tables[index].Columns[0].Name) %>(<%=GetClassName() %> <%=GetObjectName() %>)
{
return <%=GetObjectName() %>DAL.AddReturn<%=StringUtil.ToPascalCase(db.Tables[index].Columns[0].Name) %>(<%=GetObjectName() %>);
}
public int Update(<%=GetClassName() %> <%=GetObjectName() %>)
{
return <%=GetObjectName() %>DAL.Update(<%=GetObjectName() %>);
}
public int Delete(int <%=StringUtil.ToCamelCase(GetPrimaryKey()) %>)
{
return <%=GetObjectName() %>DAL.Delete(<%=StringUtil.ToCamelCase(GetPrimaryKey()) %>);
}
public List<<%=GetClassName() %>> GetAll()
{
return <%=GetObjectName() %>DAL.GetAll();
}
public <%=GetClassName() %> GetSingle(int <%=StringUtil.ToCamelCase(GetPrimaryKey()) %>)
{
return <%=GetObjectName() %>DAL.GetSingle(<%=StringUtil.ToCamelCase(GetPrimaryKey()) %>);
}
public List<<%=GetClassName() %>> GetAllByConditions(string conditions)
{
return <%=GetObjectName() %>DAL.GetAllByConditions(conditions);
}
}
}
<script runat="template">
public string GetClassName()
{
return StringUtil.ToPascalCase(db.Tables[index].Name);
}
public string GetObjectName()
{
return StringUtil.ToCamelCase(db.Tables[index].Name);
}
public string GetPrimaryKey()
{
return db.Tables[index].Columns[0].Name ;
}
public override void Render(TextWriter writer)
{
string path1 =OutputDirectory + GetClassName() + "BLL.cs";
System.Diagnostics.Trace.WriteLine(path1);
StreamWriter fileWriter1 = new StreamWriter(path1,false);
this.Response.AddTextWriter(fileWriter1);
base.Render(writer);
fileWriter1.Close();
}
private string _outputDirectory = String.Empty;
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
[Optional]
[Category("Output")]
[Description("The directory to output the results to.")]
public string OutputDirectory
{
get
{
// default to the directory that the template is located in
if (_outputDirectory.Length == 0) return this.CodeTemplateInfo.DirectoryName;
return _outputDirectory;
}
set
{
if (!value.EndsWith("//")) value += "//";
_outputDirectory = value;
}
}
</script>