namespace Ecommerce.EventHandlers { public class DomainHandler : ApplicationBase { public DomainHandler() { Domain.BeforeSave += new Domain.SaveEventHandler(RegisterDomain2Product); }
new DataHelpers.DomainHelpers.CreateRelation(dom);
} }
public class CreateRelation { private ISqlHelper sqlHelper;
//this must be used by super-admins since they dont belong to a company public CreateRelation(Domain dom) { try { var SQL = sqlHelper.ExecuteNonQuery("INSERT INTO eCommerceCompanies2Domains VALUES(@companyId, @domainId)", sqlHelper.CreateParameter("@companyId", 2), sqlHelper.CreateParameter("@domainId", 5)); } catch (Exception e) { Log.Add(LogTypes.Custom, 1, "Failed to insert into database"); }
} }
}
So what im trying to do here is to connect a new Domain to a Company in a db table
Did you try to set a breakpoint and did it got hit? Another question did you use the app_code folder to store your class? I have seen issues with events and the use of the app_code folder instead of compiling a dll.
EventHandler problem
Hi,
im trying to attach the following to umbraco:
namespace Ecommerce.EventHandlers
{
public class DomainHandler : ApplicationBase
{
public DomainHandler()
{
Domain.BeforeSave += new Domain.SaveEventHandler(RegisterDomain2Product);
}
public void RegisterDomain2Product(Domain dom, umbraco.cms.businesslogic.SaveEventArgs e)
{
Log.Add(LogTypes.Custom, dom.Id, "Saving domain");
new DataHelpers.DomainHelpers.CreateRelation(dom);
}
}
public class CreateRelation
{
private ISqlHelper sqlHelper;
//this must be used by super-admins since they dont belong to a company
public CreateRelation(Domain dom)
{
try
{
var SQL = sqlHelper.ExecuteNonQuery("INSERT INTO eCommerceCompanies2Domains VALUES(@companyId, @domainId)", sqlHelper.CreateParameter("@companyId", 2), sqlHelper.CreateParameter("@domainId", 5));
}
catch (Exception e)
{
Log.Add(LogTypes.Custom, 1, "Failed to insert into database");
}
}
}
}
So what im trying to do here is to connect a new Domain to a Company in a db table
But this event dosnt fire?
Has any on else had any problems with the Domain.AfterSave event in v4.0.3?
Hi,
Did you try to set a breakpoint and did it got hit? Another question did you use the app_code folder to store your class? I have seen issues with events and the use of the app_code folder instead of compiling a dll.
Cheers,
Richard
Hi Richard,
I use a dll file so I dont belive that to be the problem.
For now, iv changed the event to a Domain.New and this seems to work. Not sure why though =)
is working on a reply...