I am sending the Domain Object, Mapping Document, Data Access Layer Save() Method, and User Interface Code.
Domain Objects are:
public class Testplan
{
int _TestPlanID;
public int TestPlanID
{
get { return _TestPlanID; }
set { _TestPlanID = value; }
}
string _TestPlan;
public string TestPlan
{
get { return _TestPlan; }
set { _TestPlan = value; }
}
string _Description;
public string Description
{
get { return _Description; }
set { _Description = value; }
}
string _Active_Ind;
public string Active_Ind
{
get { return _Active_Ind; }
set { _Active_Ind = value; }
}
int _CreatedBy;
public int CreatedBy
{
get { return _CreatedBy; }
set { _CreatedBy = value; }
}
DateTime _CreatedDate;
public DateTime CreatedDate
{
get { return _CreatedDate; }
set { _CreatedDate = value; }
}
int _UpdatedBy;
public int UpdatedBy
{
get { return _UpdatedBy; }
set { _UpdatedBy = value; }
}
DateTime _UpdatedDate;
public DateTime UpdatedDate
{
get { return _UpdatedDate; }
set { _UpdatedDate = value; }
}
string _Disabled;
public string Disabled
{
get { return _Disabled; }
set { _Disabled = value; }
}
}
Mapping document:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Dev.Medho.TestEnh.Kasyapa.DTO"
namespace="Dev.Medho.TestEnh.Kasyapa.DTO.Domain.Screens">
<class name="Testplan" table="TestPlan" lazy="false">
<id name="TestPlanID" unsaved-value="0">
<generator class="sequence">
<param name="sequence">TestPlan_seq</param>
</generator>
</id>
<property name="TestPlan" />
<property name="Description" />
<property name="Active_Ind" />
<property name="CreatedBy" />
<property name="CreatedDate"/>
<property name="UpdatedBy" />
<property name="UpdatedDate" />
<property name="Disabled" />
</class>
</hibernate-mapping>
In Data Access Layer:
public void Save(Testplan newTestPlan)
{
if (log.IsDebugEnabled) log.Debug("Entered Save method");
try
{
session.SaveOrUpdateCopy(newTestPlan);
}
catch (Exception ex)
{
if (log.IsErrorEnabled)
log.Error("Cannot SaveTestplan", ex);
}
if (log.IsDebugEnabled) log.Debug("Leave Save Method");
}
In User Interface:
protected void btnInsert_Click(object sender, EventArgs e)
{
Testplan newTestPlan = new Testplan();
newTestPlan.TestPlan = txtTestPlan.Text;
newTestPlan.Description = txtDescription.Text;
newTestPlan.Active_Ind = "T";
newTestPlan.CreatedBy = 1;
newTestPlan.CreatedDate = DateTime.Today;
newTestPlan.UpdatedBy = 1;
newTestPlan.UpdatedDate = DateTime.Today;
newTestPlan.Disabled = "T";
testPlanBL.SaveTestPlanDetails(newTestPlan);
}
Please verify the code and suggest where I have wrong.
|