Generalised lead entries

This commit is contained in:
Khwezi Mngoma
2026-05-05 14:06:38 +02:00
parent 33112dcf79
commit f5c9557f59
10 changed files with 457 additions and 15 deletions
@@ -9,11 +9,11 @@ public class CreateLeadCommandHandler(IDbContextFactory<LeadGeneratorDbContext>
{
try
{
var hashCommand = ComputeHashCommand.Create($"{request.GoogleClickId}{request.AppClickId}{request.WebClickId}");
var hashCommand = ComputeHashCommand.Create($"{request.ClickId}{request.AppClickId}{request.WebClickId}");
var hashResult = await mediator.Send(hashCommand, cancellationToken);
if(hashResult.IsFailed)
return Result.Fail<Guid>(new Error($"Failed to compute hash for lead -> Google ClickId: {request.GoogleClickId}, App ClickId: {request.AppClickId}, Web ClickId: {request.WebClickId}")
return Result.Fail<Guid>(new Error($"Failed to compute hash for lead -> Google ClickId: {request.ClickId}, App ClickId: {request.AppClickId}, Web ClickId: {request.WebClickId}")
.CausedBy(hashResult.Errors));
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
@@ -22,7 +22,8 @@ public class CreateLeadCommandHandler(IDbContextFactory<LeadGeneratorDbContext>
{
WebClickId = request.WebClickId,
AppClickId = request.AppClickId,
GoogleClickId = request.GoogleClickId,
Source = request.Source,
ClickId = request.ClickId,
AdGroupId = request.AdGroupId,
AdName = request.AdName,
CampaignId = request.CampaignId,
@@ -36,7 +37,7 @@ public class CreateLeadCommandHandler(IDbContextFactory<LeadGeneratorDbContext>
return await context.SaveChangesAsync(cancellationToken) > 0
? Result.Ok(newLead.Entity.Id)
: Result.Fail<Guid>(new Error($"Failed to create lead -> Google ClickId: {request.GoogleClickId}, App ClickId: {request.AppClickId}, Web ClickId: {request.WebClickId}"));
: Result.Fail<Guid>(new Error($"Failed to create lead -> Google ClickId: {request.ClickId}, App ClickId: {request.AppClickId}, Web ClickId: {request.WebClickId}"));
}
catch (Exception ex)
{