This commit is contained in:
@@ -65,15 +65,15 @@ namespace AyaNova.Biz
|
||||
//
|
||||
internal async Task<long?> CustomerCreateAsync(CustomerPostUnit postObject)
|
||||
{
|
||||
|
||||
|
||||
Unit newObject=new Unit();
|
||||
newObject.Active=true;
|
||||
newObject.Notes="This unit was added by a Customer";
|
||||
newObject.Serial=postObject.Serial;
|
||||
newObject.Description=postObject.Description;
|
||||
newObject.CustomerId=postObject.CustomerId;
|
||||
newObject.UnitModelId=postObject.UnitModelId;
|
||||
|
||||
Unit newObject = new Unit();
|
||||
newObject.Active = true;
|
||||
newObject.Notes = "This unit was added by a Customer";
|
||||
newObject.Serial = postObject.Serial;
|
||||
newObject.Description = postObject.Description;
|
||||
newObject.CustomerId = postObject.CustomerId;
|
||||
newObject.UnitModelId = postObject.UnitModelId;
|
||||
await ValidateAsync(newObject, null);
|
||||
if (HasErrors)
|
||||
return null;
|
||||
@@ -159,7 +159,7 @@ namespace AyaNova.Biz
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
{
|
||||
{
|
||||
var IDList = await ct.Review.AsNoTracking().Where(x => x.AType == AyaType.Unit && x.ObjectId == id).Select(x => x.Id).ToListAsync();
|
||||
if (IDList.Count() > 0)
|
||||
{
|
||||
@@ -248,7 +248,7 @@ namespace AyaNova.Biz
|
||||
//(two different manufacturers products could have the same serial easily, but it's less likely for two different units of the same unitmodel)
|
||||
//
|
||||
if (!PropertyHasErrors("Serial"))
|
||||
{
|
||||
{
|
||||
//Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
|
||||
if (await ct.Unit.AnyAsync(z => z.Serial == proposedObj.Serial && z.UnitModelId == proposedObj.UnitModelId && z.Id != proposedObj.Id))
|
||||
{
|
||||
@@ -305,6 +305,7 @@ namespace AyaNova.Biz
|
||||
var batchResults = await ct.Unit.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
||||
//order the results back into original
|
||||
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||
batchResults = null;
|
||||
foreach (Unit w in orderedList)
|
||||
{
|
||||
if (!ReportRenderManager.KeepGoing(jobId)) return null;
|
||||
@@ -314,28 +315,56 @@ namespace AyaNova.Biz
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
ReportData.Add(jo);
|
||||
}
|
||||
orderedList = null;
|
||||
}
|
||||
vc.Clear();
|
||||
return ReportData;
|
||||
}
|
||||
private VizCache vc = new VizCache();
|
||||
|
||||
//populate viz fields from provided object
|
||||
private async Task PopulateVizFields(Unit o)
|
||||
{
|
||||
o.CustomerViz = await ct.Customer.AsNoTracking().Where(x => x.Id == o.CustomerId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
if (!vc.Has("customer", o.CustomerId))
|
||||
vc.Add(await ct.Customer.AsNoTracking().Where(x => x.Id == o.CustomerId).Select(x => x.Name).FirstOrDefaultAsync(), "customer", o.CustomerId);
|
||||
o.CustomerViz = vc.Get("customer", o.CustomerId);
|
||||
|
||||
if (o.UnitModelId != null)
|
||||
o.UnitModelNameViz = await ct.UnitModel.AsNoTracking().Where(x => x.Id == o.UnitModelId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
{
|
||||
if (!vc.Has("unitmodel", o.UnitModelId))
|
||||
vc.Add(await ct.UnitModel.AsNoTracking().Where(x => x.Id == o.UnitModelId).Select(x => x.Name).FirstOrDefaultAsync(), "unitmodel", o.UnitModelId);
|
||||
o.UnitModelNameViz = vc.Get("unitmodel", o.UnitModelId);
|
||||
}
|
||||
|
||||
if (o.ParentUnitId != null)
|
||||
o.ParentUnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.ParentUnitId).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||
{
|
||||
if (!vc.Has("unitserial", o.ParentUnitId))
|
||||
vc.Add(await ct.Unit.AsNoTracking().Where(x => x.Id == o.ParentUnitId).Select(x => x.Serial).FirstOrDefaultAsync(), "unitserial", o.ParentUnitId);
|
||||
o.ParentUnitViz = vc.Get("unitserial", o.ParentUnitId);
|
||||
}
|
||||
|
||||
if (o.ReplacedByUnitId != null)
|
||||
o.ReplacedByUnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.ReplacedByUnitId).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||
{
|
||||
if (!vc.Has("unitserial", o.ReplacedByUnitId))
|
||||
vc.Add(await ct.Unit.AsNoTracking().Where(x => x.Id == o.ReplacedByUnitId).Select(x => x.Serial).FirstOrDefaultAsync(), "unitserial", o.ReplacedByUnitId);
|
||||
o.ReplacedByUnitViz = vc.Get("unitserial", o.ReplacedByUnitId);
|
||||
}
|
||||
|
||||
if (o.PurchasedFromVendorId != null)
|
||||
o.PurchasedFromVendorViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.PurchasedFromVendorId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
|
||||
{
|
||||
if (!vc.Has("vendorname", o.PurchasedFromVendorId))
|
||||
vc.Add(await ct.Vendor.AsNoTracking().Where(x => x.Id == o.PurchasedFromVendorId).Select(x => x.Name).FirstOrDefaultAsync(), "vendorname", o.PurchasedFromVendorId);
|
||||
o.PurchasedFromVendorViz = vc.Get("vendorname", o.PurchasedFromVendorId);
|
||||
}
|
||||
|
||||
if (o.ContractId != null)
|
||||
o.ContractViz = await ct.Contract.AsNoTracking().Where(x => x.Id == o.ContractId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
{
|
||||
if (!vc.Has("contract", o.ContractId))
|
||||
{
|
||||
vc.Add(await ct.Contract.AsNoTracking().Where(x => x.Id == o.ContractId).Select(x => x.Name).FirstOrDefaultAsync(), "contract", o.ContractId);
|
||||
}
|
||||
o.ContractViz = vc.Get("contract", o.ContractId);
|
||||
}
|
||||
|
||||
if (o.Metered)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user