This commit is contained in:
2023-04-21 22:22:11 +00:00
parent 4c603cb648
commit 9d2a9af98a
2 changed files with 15 additions and 14 deletions

View File

@@ -304,7 +304,7 @@ namespace Sockeye.Biz
if (!ReportRenderManager.KeepGoing(jobId)) return null;
//var subId = .Select(z => z.SubscriptionId).FirstOrDefaultAsync();
var subItem = await ct.SubscriptionItem.AsNoTracking().Where(z => z.Id == batchId).FirstOrDefaultAsync();
await PopulateItemVizFields(subItem, 0);
await PopulateItemVizFields(subItem);
batchResults.Add(subItem);
}
@@ -336,7 +336,7 @@ namespace Sockeye.Biz
foreach (var item in o.Items)//some subscriptions have a bunch of the same monthly or yearly raven user in them so this will save in that case
{
await PopulateItemVizFields(item, o.CustomerId);
await PopulateItemVizFields(item, o);
// if (!vc.Has("productname", item.ProductId))
// {
// var productInfo = await ct.Product.AsNoTracking().Where(x => x.Id == item.ProductId).FirstOrDefaultAsync();
@@ -352,23 +352,22 @@ namespace Sockeye.Biz
}
//populate viz fields from provided object
private async Task PopulateItemVizFields(SubscriptionItem o, long CustomerId)
private async Task PopulateItemVizFields(SubscriptionItem o, Subscription sub = null)
{
if (CustomerId == 0)
CustomerId = await ct.Subscription.Where(z => z.Id == o.SubscriptionId).Select(z => z.CustomerId).FirstOrDefaultAsync();
if (sub == null)
sub = await ct.Subscription.AsNoTracking().Where(z => z.Id == o.SubscriptionId).FirstOrDefaultAsync();
o.SubscriptionEmailViz = sub.FetchEmail;
if (CustomerId != 0)
if (!vc.Has("customername", sub.CustomerId))
{
if (!vc.Has("customername", CustomerId))
{
var custInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == CustomerId).FirstOrDefaultAsync();
vc.Add(custInfo.Name, "customername", CustomerId);
vc.Add(custInfo.EmailAddress, "customeremail", CustomerId);
}
o.CustomerViz = vc.Get("customername", CustomerId);
o.CustomerEmailViz = vc.Get("customeremail", CustomerId);
var custInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == sub.CustomerId).FirstOrDefaultAsync();
vc.Add(custInfo.Name, "customername", sub.CustomerId);
vc.Add(custInfo.EmailAddress, "customeremail", sub.CustomerId);
}
o.CustomerViz = vc.Get("customername", sub.CustomerId);
o.CustomerEmailViz = vc.Get("customeremail", sub.CustomerId);
if (!vc.Has("productname", o.ProductId))
{

View File

@@ -43,6 +43,8 @@ namespace Sockeye.Models
public string CustomerViz { get; set; }
[NotMapped]
public string CustomerEmailViz { get; set; }
[NotMapped]
public string SubscriptionEmailViz { get; set; }
public List<string> Tags { get; set; } = new List<string>();