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; if (!ReportRenderManager.KeepGoing(jobId)) return null;
//var subId = .Select(z => z.SubscriptionId).FirstOrDefaultAsync(); //var subId = .Select(z => z.SubscriptionId).FirstOrDefaultAsync();
var subItem = await ct.SubscriptionItem.AsNoTracking().Where(z => z.Id == batchId).FirstOrDefaultAsync(); var subItem = await ct.SubscriptionItem.AsNoTracking().Where(z => z.Id == batchId).FirstOrDefaultAsync();
await PopulateItemVizFields(subItem, 0); await PopulateItemVizFields(subItem);
batchResults.Add(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 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)) // if (!vc.Has("productname", item.ProductId))
// { // {
// var productInfo = await ct.Product.AsNoTracking().Where(x => x.Id == item.ProductId).FirstOrDefaultAsync(); // 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 //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) if (sub == null)
CustomerId = await ct.Subscription.Where(z => z.Id == o.SubscriptionId).Select(z => z.CustomerId).FirstOrDefaultAsync(); 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 == sub.CustomerId).FirstOrDefaultAsync();
{ vc.Add(custInfo.Name, "customername", sub.CustomerId);
var custInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == CustomerId).FirstOrDefaultAsync(); vc.Add(custInfo.EmailAddress, "customeremail", sub.CustomerId);
vc.Add(custInfo.Name, "customername", CustomerId);
vc.Add(custInfo.EmailAddress, "customeremail", CustomerId);
}
o.CustomerViz = vc.Get("customername", CustomerId);
o.CustomerEmailViz = vc.Get("customeremail", CustomerId);
} }
o.CustomerViz = vc.Get("customername", sub.CustomerId);
o.CustomerEmailViz = vc.Get("customeremail", sub.CustomerId);
if (!vc.Has("productname", o.ProductId)) if (!vc.Has("productname", o.ProductId))
{ {

View File

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