diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 2400183d..ab62bd89 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -244,9 +244,10 @@ namespace AyaNova.Util await SeedPartWarehouseAsync(log, 5); await SeedPartAsync(log, 20, 100); await SeedPartAssemblyAsync(log, 5); - await SeedPurchaseOrderAsync(log, 20); + await SeedPurchaseOrderAsync(log, 10); await SeedQuoteAsync(log, 5); - await SeedWorkOrderAsync(log, 25); + await SeedPMAsync(log, 3); + await SeedWorkOrderAsync(log, 10); //PERF watch.Stop(); @@ -304,6 +305,7 @@ namespace AyaNova.Util await SeedPartAssemblyAsync(log, 5); await SeedPurchaseOrderAsync(log, 30); await SeedQuoteAsync(log, 5); + await SeedPMAsync(log, 3); await SeedWorkOrderAsync(log, 75); //PERF @@ -372,6 +374,7 @@ namespace AyaNova.Util await SeedPartAssemblyAsync(log, 5); await SeedPurchaseOrderAsync(log, 50); await SeedQuoteAsync(log, 5); + await SeedPMAsync(log, 3); await SeedWorkOrderAsync(log, 150); //PERF @@ -441,6 +444,7 @@ namespace AyaNova.Util await SeedPartAssemblyAsync(log, 25); await SeedPurchaseOrderAsync(log, 250); await SeedQuoteAsync(log, 5); + await SeedPMAsync(log, 3); await SeedWorkOrderAsync(log, 300); //PERF @@ -3694,25 +3698,25 @@ namespace AyaNova.Util var woDate = DesiredTimeInUtc(new DateTime(tempDate.Year, tempDate.Month, tempDate.Day, tempHour, 0, 0)); o.CreatedDate = DateTime.UtcNow; - + o.CustomerId = GetRandomCustomerId();//Fake.Random.Long(1, TotalSeededCustomers); -//------ - o.StopGeneratingDate=woDate.AddYears(1); - o.ExcludeDaysOfWeek= new bool[]{true,true,true,true,true,false,false};//Monday to Sunday (0-6 index) - o.Active=true; - o.NextServiceDate=woDate.AddDays(1); - o.RepeatInterval=1; - o.RepeatUnit= PMTimeUnit.Months; - o.GenerateBeforeInterval=3; - o.GenerateBeforeUnit=PMTimeUnit.Days; - //------ + //------ + o.StopGeneratingDate = woDate.AddYears(1); + o.ExcludeDaysOfWeek = new bool[] { true, true, true, true, true, false, false };//Monday to Sunday (0-6 index) + o.Active = true; + o.NextServiceDate = woDate.AddDays(1); + o.RepeatInterval = 1; + o.RepeatUnit = PMTimeUnit.Months; + o.GenerateBeforeInterval = 3; + o.GenerateBeforeUnit = PMTimeUnit.Days; + //------ using (AyContext ct = ServiceProviderProvider.DBContext) { var cust = await ct.Customer.AsNoTracking().FirstAsync(z => z.Id == o.CustomerId); - o.Latitude = cust.Latitude; + o.Latitude = cust.Latitude; o.Longitude = cust.Longitude; o.Address = cust.Address; o.City = cust.City; @@ -3723,353 +3727,353 @@ namespace AyaNova.Util if (cust.BillHeadOffice && cust.HeadOfficeId != null) { var head = await ct.HeadOffice.AsNoTracking().FirstAsync(z => z.Id == cust.HeadOfficeId); - o.PostAddress = head.PostAddress; + o.PostAddress = head.PostAddress; o.PostCity = head.PostCity; o.PostRegion = head.PostRegion; o.PostCountry = head.PostCountry; o.PostCode = head.PostCode; } else -{ + { - o.PostAddress = cust.PostAddress; - o.PostCity = cust.PostCity; - o.PostRegion = cust.PostRegion; - o.PostCountry = cust.PostCountry; - o.PostCode = cust.PostCode; -} + o.PostAddress = cust.PostAddress; + o.PostCity = cust.PostCity; + o.PostRegion = cust.PostRegion; + o.PostCountry = cust.PostCountry; + o.PostCode = cust.PostCode; + } } o.CustomerReferenceNumber = "crf-" + Fake.Finance.Account(4); -o.InternalReferenceNumber = "irf-" + Fake.Finance.Account(4); -//o.ServiceDate = woDate; + o.InternalReferenceNumber = "irf-" + Fake.Finance.Account(4); + //o.ServiceDate = woDate; -int woItemCount = Fake.Random.Int(1, 2); -for (int y = 0; y < woItemCount; y++) -{ - var woItem = new PMItem() - { - Sequence = y + 1, - Notes = $"itemnotes - {y} ", - TechNotes = $"technotes - {y}", - RequestDate = woDate.AddMinutes(y), - WorkOrderItemPriorityId = Fake.Random.Long(1, 5),//there are 5 different sample priorities - WorkOrderItemStatusId = Fake.Random.Long(1, 3)//there are 3 different sample woitem status - }; + int woItemCount = Fake.Random.Int(1, 2); + for (int y = 0; y < woItemCount; y++) + { + var woItem = new PMItem() + { + Sequence = y + 1, + Notes = $"itemnotes - {y} ", + TechNotes = $"technotes - {y}", + RequestDate = woDate.AddMinutes(y), + WorkOrderItemPriorityId = Fake.Random.Long(1, 5),//there are 5 different sample priorities + WorkOrderItemStatusId = Fake.Random.Long(1, 3)//there are 3 different sample woitem status + }; - //UNITS - var woItemUnit = new PMItemUnit() - { - UnitId = GetRandomUnitForCustomer(o.CustomerId), - Notes = Fake.Lorem.Sentence() - }; - woItem.Units.Add(woItemUnit); + //UNITS + var woItemUnit = new PMItemUnit() + { + UnitId = GetRandomUnitForCustomer(o.CustomerId), + Notes = Fake.Lorem.Sentence() + }; + woItem.Units.Add(woItemUnit); - woItemUnit = new PMItemUnit() - { - UnitId = GetRandomUnitForCustomer(o.CustomerId), - Notes = Fake.Lorem.Sentence() - }; - woItem.Units.Add(woItemUnit); + woItemUnit = new PMItemUnit() + { + UnitId = GetRandomUnitForCustomer(o.CustomerId), + Notes = Fake.Lorem.Sentence() + }; + woItem.Units.Add(woItemUnit); - //SCHEDULED USERS - var woItemScheduledUser = new PMItemScheduledUser() - { - UserId = RandomServiceTechUserId(), - EstimatedQuantity = 1, - StartDate = woDate, - StopDate = woDate.AddHours(1) - }; - woItem.ScheduledUsers.Add(woItemScheduledUser); + //SCHEDULED USERS + var woItemScheduledUser = new PMItemScheduledUser() + { + UserId = RandomServiceTechUserId(), + EstimatedQuantity = 1, + StartDate = woDate, + StopDate = woDate.AddHours(1) + }; + woItem.ScheduledUsers.Add(woItemScheduledUser); - woItemScheduledUser = new PMItemScheduledUser() - { - UserId = RandomServiceTechUserId(), - EstimatedQuantity = 2, - StartDate = woDate, - StopDate = woDate.AddHours(1) - }; - woItem.ScheduledUsers.Add(woItemScheduledUser); + woItemScheduledUser = new PMItemScheduledUser() + { + UserId = RandomServiceTechUserId(), + EstimatedQuantity = 2, + StartDate = woDate, + StopDate = woDate.AddHours(1) + }; + woItem.ScheduledUsers.Add(woItemScheduledUser); - if (y == 1) - { - //known tech and subcontractor on every item - woItemScheduledUser = new PMItemScheduledUser() - { - UserId = KnownUserTechId, - EstimatedQuantity = 2, - StartDate = woDate, - StopDate = woDate.AddHours(2) - }; - woItem.ScheduledUsers.Add(woItemScheduledUser); + if (y == 1) + { + //known tech and subcontractor on every item + woItemScheduledUser = new PMItemScheduledUser() + { + UserId = KnownUserTechId, + EstimatedQuantity = 2, + StartDate = woDate, + StopDate = woDate.AddHours(2) + }; + woItem.ScheduledUsers.Add(woItemScheduledUser); - woItemScheduledUser = new PMItemScheduledUser() - { - UserId = KnownUserSubContractorId, - EstimatedQuantity = 2, - StartDate = woDate, - StopDate = woDate.AddHours(2) - }; - woItem.ScheduledUsers.Add(woItemScheduledUser); - } + woItemScheduledUser = new PMItemScheduledUser() + { + UserId = KnownUserSubContractorId, + EstimatedQuantity = 2, + StartDate = woDate, + StopDate = woDate.AddHours(2) + }; + woItem.ScheduledUsers.Add(woItemScheduledUser); + } - if (y == 3) - { - //known restricted tech and subcontractor on some items - woItemScheduledUser = new PMItemScheduledUser() - { - UserId = KnownUserTechRestrictedId, - EstimatedQuantity = 2, - StartDate = woDate, - StopDate = woDate.AddHours(2) - }; - woItem.ScheduledUsers.Add(woItemScheduledUser); + if (y == 3) + { + //known restricted tech and subcontractor on some items + woItemScheduledUser = new PMItemScheduledUser() + { + UserId = KnownUserTechRestrictedId, + EstimatedQuantity = 2, + StartDate = woDate, + StopDate = woDate.AddHours(2) + }; + woItem.ScheduledUsers.Add(woItemScheduledUser); - woItemScheduledUser = new PMItemScheduledUser() - { - UserId = KnownUserSubContractorRestrictedId, - EstimatedQuantity = 2, - StartDate = woDate, - StopDate = woDate.AddHours(2) - }; - woItem.ScheduledUsers.Add(woItemScheduledUser); - } + woItemScheduledUser = new PMItemScheduledUser() + { + UserId = KnownUserSubContractorRestrictedId, + EstimatedQuantity = 2, + StartDate = woDate, + StopDate = woDate.AddHours(2) + }; + woItem.ScheduledUsers.Add(woItemScheduledUser); + } - //PARTS - var woItemPart = new PMItemPart() - { + //PARTS + var woItemPart = new PMItemPart() + { - Quantity = 1, - PartId = Fake.Random.Long(1, TotalSeededParts), - PartWarehouseId = 1 - }; - woItem.Parts.Add(woItemPart); + Quantity = 1, + PartId = Fake.Random.Long(1, TotalSeededParts), + PartWarehouseId = 1 + }; + woItem.Parts.Add(woItemPart); - woItemPart = new PMItemPart() - { + woItemPart = new PMItemPart() + { - Quantity = 1, - PartId = Fake.Random.Long(1, TotalSeededParts), - PartWarehouseId = 1 - }; - woItem.Parts.Add(woItemPart); + Quantity = 1, + PartId = Fake.Random.Long(1, TotalSeededParts), + PartWarehouseId = 1 + }; + woItem.Parts.Add(woItemPart); - //LOANERS - var woItemLoan = new PMItemLoan() - { - OutDate = woDate.AddHours(1), - DueDate = woDate.AddHours(4), - Quantity = 4, - Rate = LoanUnitRateUnit.Hours, - LoanUnitId = Fake.Random.Long(1, TotalSeededLoanUnits) - }; - woItem.Loans.Add(woItemLoan); + //LOANERS + var woItemLoan = new PMItemLoan() + { + OutDate = woDate.AddHours(1), + DueDate = woDate.AddHours(4), + Quantity = 4, + Rate = LoanUnitRateUnit.Hours, + LoanUnitId = Fake.Random.Long(1, TotalSeededLoanUnits) + }; + woItem.Loans.Add(woItemLoan); - woItemLoan = new PMItemLoan() - { - OutDate = woDate.AddHours(2), - DueDate = woDate.AddHours(3), - Quantity = 1, - Rate = LoanUnitRateUnit.Hours, - LoanUnitId = Fake.Random.Long(1, TotalSeededLoanUnits) - }; - woItem.Loans.Add(woItemLoan); + woItemLoan = new PMItemLoan() + { + OutDate = woDate.AddHours(2), + DueDate = woDate.AddHours(3), + Quantity = 1, + Rate = LoanUnitRateUnit.Hours, + LoanUnitId = Fake.Random.Long(1, TotalSeededLoanUnits) + }; + woItem.Loans.Add(woItemLoan); - //LABOR - var techId = RandomServiceTechUserId(); - var woItemLabor = new PMItemLabor() - { - UserId = techId, - ServiceRateQuantity = 1, - ServiceStartDate = woDate, - ServiceStopDate = woDate.AddHours(1), - ServiceRateId = Fake.Random.Long(1, TotalSeededServiceRates), - ServiceDetails = Fake.Lorem.Sentence() - }; - woItem.Labors.Add(woItemLabor); + //LABOR + var techId = RandomServiceTechUserId(); + var woItemLabor = new PMItemLabor() + { + UserId = techId, + ServiceRateQuantity = 1, + ServiceStartDate = woDate, + ServiceStopDate = woDate.AddHours(1), + ServiceRateId = Fake.Random.Long(1, TotalSeededServiceRates), + ServiceDetails = Fake.Lorem.Sentence() + }; + woItem.Labors.Add(woItemLabor); - woItemLabor = new PMItemLabor() - { - UserId = RandomServiceTechUserId(), - ServiceRateQuantity = 2, - ServiceStartDate = woDate, - ServiceStopDate = woDate.AddHours(1), - ServiceRateId = Fake.Random.Long(1, TotalSeededServiceRates), - ServiceDetails = Fake.Lorem.Sentence() - }; - woItem.Labors.Add(woItemLabor); + woItemLabor = new PMItemLabor() + { + UserId = RandomServiceTechUserId(), + ServiceRateQuantity = 2, + ServiceStartDate = woDate, + ServiceStopDate = woDate.AddHours(1), + ServiceRateId = Fake.Random.Long(1, TotalSeededServiceRates), + ServiceDetails = Fake.Lorem.Sentence() + }; + woItem.Labors.Add(woItemLabor); - //TRAVEL - var woItemTravel = new PMItemTravel() - { - UserId = techId, - TravelRateQuantity = 1, - TravelStartDate = woDate, - TravelStopDate = woDate.AddHours(1), - TravelRateId = Fake.Random.Long(1, TotalSeededTravelRates), - TravelDetails = Fake.Lorem.Sentence(), - Distance = Fake.Random.Decimal(1.0m, 20.0m) - }; - woItem.Travels.Add(woItemTravel); + //TRAVEL + var woItemTravel = new PMItemTravel() + { + UserId = techId, + TravelRateQuantity = 1, + TravelStartDate = woDate, + TravelStopDate = woDate.AddHours(1), + TravelRateId = Fake.Random.Long(1, TotalSeededTravelRates), + TravelDetails = Fake.Lorem.Sentence(), + Distance = Fake.Random.Decimal(1.0m, 20.0m) + }; + woItem.Travels.Add(woItemTravel); - woItemTravel = new PMItemTravel() - { - UserId = RandomServiceTechUserId(), - TravelRateQuantity = 2, - TravelStartDate = woDate, - TravelStopDate = woDate.AddHours(1), - TravelRateId = Fake.Random.Long(1, TotalSeededTravelRates), - TravelDetails = Fake.Lorem.Sentence(), - Distance = Fake.Random.Decimal(1.0m, 20.0m) - }; - woItem.Travels.Add(woItemTravel); + woItemTravel = new PMItemTravel() + { + UserId = RandomServiceTechUserId(), + TravelRateQuantity = 2, + TravelStartDate = woDate, + TravelStopDate = woDate.AddHours(1), + TravelRateId = Fake.Random.Long(1, TotalSeededTravelRates), + TravelDetails = Fake.Lorem.Sentence(), + Distance = Fake.Random.Decimal(1.0m, 20.0m) + }; + woItem.Travels.Add(woItemTravel); - //TASKS - var woItemTask = new PMItemTask() - { - CompletedByUserId = techId, - Task = "Dis-assemble", - Sequence = 1, - Status = WorkorderItemTaskCompletionType.Incomplete - }; - woItem.Tasks.Add(woItemTask); + //TASKS + var woItemTask = new PMItemTask() + { + CompletedByUserId = techId, + Task = "Dis-assemble", + Sequence = 1, + Status = WorkorderItemTaskCompletionType.Incomplete + }; + woItem.Tasks.Add(woItemTask); - woItemTask = new PMItemTask() - { - CompletedByUserId = techId, - Task = "Lubricate", - Sequence = 2, - Status = WorkorderItemTaskCompletionType.Incomplete - }; - woItem.Tasks.Add(woItemTask); + woItemTask = new PMItemTask() + { + CompletedByUserId = techId, + Task = "Lubricate", + Sequence = 2, + Status = WorkorderItemTaskCompletionType.Incomplete + }; + woItem.Tasks.Add(woItemTask); - woItemTask = new PMItemTask() - { - CompletedByUserId = techId, - Task = "Repair", - Sequence = 3, - Status = WorkorderItemTaskCompletionType.Incomplete - }; - woItem.Tasks.Add(woItemTask); + woItemTask = new PMItemTask() + { + CompletedByUserId = techId, + Task = "Repair", + Sequence = 3, + Status = WorkorderItemTaskCompletionType.Incomplete + }; + woItem.Tasks.Add(woItemTask); - woItemTask = new PMItemTask() - { - CompletedByUserId = techId, - Task = "Re-assemble", - Sequence = 4, - Status = WorkorderItemTaskCompletionType.Incomplete - }; - woItem.Tasks.Add(woItemTask); + woItemTask = new PMItemTask() + { + CompletedByUserId = techId, + Task = "Re-assemble", + Sequence = 4, + Status = WorkorderItemTaskCompletionType.Incomplete + }; + woItem.Tasks.Add(woItemTask); - woItemTask = new PMItemTask() - { - CompletedByUserId = techId, - Task = "Test and confirm repair", - Sequence = 5, - Status = WorkorderItemTaskCompletionType.Incomplete - }; - woItem.Tasks.Add(woItemTask); + woItemTask = new PMItemTask() + { + CompletedByUserId = techId, + Task = "Test and confirm repair", + Sequence = 5, + Status = WorkorderItemTaskCompletionType.Incomplete + }; + woItem.Tasks.Add(woItemTask); - //EXPENSES - var cost = Fake.Random.Decimal(1, 10); - var woItemExpense = new PMItemExpense() - { - UserId = RandomServiceTechUserId(), - //TotalCost = cost, - ChargeAmount = cost * 1.2m, - ChargeToCustomer = true, - ReimburseUser = true, - ChargeTaxCodeId = TCGoods, - Name = Fake.Commerce.ProductName() + //EXPENSES + var cost = Fake.Random.Decimal(1, 10); + var woItemExpense = new PMItemExpense() + { + UserId = RandomServiceTechUserId(), + //TotalCost = cost, + ChargeAmount = cost * 1.2m, + ChargeToCustomer = true, + ReimburseUser = true, + ChargeTaxCodeId = TCGoods, + Name = Fake.Commerce.ProductName() - }; - woItem.Expenses.Add(woItemExpense); + }; + woItem.Expenses.Add(woItemExpense); - woItemExpense = new PMItemExpense() - { - UserId = RandomServiceTechUserId(), - // TotalCost = cost * 2m, - ChargeAmount = cost * 2.2m, - ChargeToCustomer = true, - ReimburseUser = true, - ChargeTaxCodeId = TCGoods, - Name = Fake.Commerce.ProductName() + woItemExpense = new PMItemExpense() + { + UserId = RandomServiceTechUserId(), + // TotalCost = cost * 2m, + ChargeAmount = cost * 2.2m, + ChargeToCustomer = true, + ReimburseUser = true, + ChargeTaxCodeId = TCGoods, + Name = Fake.Commerce.ProductName() - }; - woItem.Expenses.Add(woItemExpense); + }; + woItem.Expenses.Add(woItemExpense); - //OUTSIDE SERVICES - var ShippingCost = Fake.Random.Decimal(5, 20); - var RepairCost = Fake.Random.Decimal(50, 1000); - var woItemOutsideService = new PMItemOutsideService() - { - UnitId = GetRandomUnitForCustomer(o.CustomerId), - Notes = Fake.Lorem.Sentence(), - VendorSentToId = Fake.Random.Long(1, TotalSeededVendors), - VendorSentViaId = Fake.Random.Long(1, TotalSeededVendors), - RMANumber = "RMA" + Fake.Finance.Account(6), - TrackingNumber = "TR" + Fake.Finance.Account(8), - RepairCost = RepairCost, - RepairPrice = RepairCost * 1.5m, - ShippingCost = ShippingCost, - ShippingPrice = ShippingCost * 1.5m, - SentDate = woDate, - ETADate = woDate.AddDays(7), - ReturnDate = woDate.AddDays(8), - TaxCodeId = 1 - }; - woItem.OutsideServices.Add(woItemOutsideService); + //OUTSIDE SERVICES + var ShippingCost = Fake.Random.Decimal(5, 20); + var RepairCost = Fake.Random.Decimal(50, 1000); + var woItemOutsideService = new PMItemOutsideService() + { + UnitId = GetRandomUnitForCustomer(o.CustomerId), + Notes = Fake.Lorem.Sentence(), + VendorSentToId = Fake.Random.Long(1, TotalSeededVendors), + VendorSentViaId = Fake.Random.Long(1, TotalSeededVendors), + RMANumber = "RMA" + Fake.Finance.Account(6), + TrackingNumber = "TR" + Fake.Finance.Account(8), + RepairCost = RepairCost, + RepairPrice = RepairCost * 1.5m, + ShippingCost = ShippingCost, + ShippingPrice = ShippingCost * 1.5m, + SentDate = woDate, + ETADate = woDate.AddDays(7), + ReturnDate = woDate.AddDays(8), + TaxCodeId = 1 + }; + woItem.OutsideServices.Add(woItemOutsideService); - ShippingCost = Fake.Random.Decimal(5, 20); - RepairCost = Fake.Random.Decimal(50, 1000); - woItemOutsideService = new PMItemOutsideService() - { - UnitId = GetRandomUnitForCustomer(o.CustomerId), - Notes = Fake.Lorem.Sentence(), - VendorSentToId = Fake.Random.Long(1, TotalSeededVendors), - VendorSentViaId = Fake.Random.Long(1, TotalSeededVendors), - RMANumber = "RMA" + Fake.Finance.Account(6), - TrackingNumber = "TR" + Fake.Finance.Account(8), - RepairCost = RepairCost, - RepairPrice = RepairCost * 1.5m, - ShippingCost = ShippingCost, - ShippingPrice = ShippingCost * 1.5m, - SentDate = woDate, - ETADate = woDate.AddDays(7), - ReturnDate = woDate.AddDays(8), - TaxCodeId = 1 - }; - woItem.OutsideServices.Add(woItemOutsideService); + ShippingCost = Fake.Random.Decimal(5, 20); + RepairCost = Fake.Random.Decimal(50, 1000); + woItemOutsideService = new PMItemOutsideService() + { + UnitId = GetRandomUnitForCustomer(o.CustomerId), + Notes = Fake.Lorem.Sentence(), + VendorSentToId = Fake.Random.Long(1, TotalSeededVendors), + VendorSentViaId = Fake.Random.Long(1, TotalSeededVendors), + RMANumber = "RMA" + Fake.Finance.Account(6), + TrackingNumber = "TR" + Fake.Finance.Account(8), + RepairCost = RepairCost, + RepairPrice = RepairCost * 1.5m, + ShippingCost = ShippingCost, + ShippingPrice = ShippingCost * 1.5m, + SentDate = woDate, + ETADate = woDate.AddDays(7), + ReturnDate = woDate.AddDays(8), + TaxCodeId = 1 + }; + woItem.OutsideServices.Add(woItemOutsideService); - o.Items.Add(woItem); -} + o.Items.Add(woItem); + } -//This seems wrong to do in a loop but is 4 times faster this way ?!? -using (AyContext ct = ServiceProviderProvider.DBContext) -{ - PMBiz biz = PMBiz.GetBiz(ct); - var NewObject = await biz.PMCreateAsync(o, false); - TotalSeededPMs++; - if (NewObject == null) - { - var err = $"Seeder::SeedPM error creating {o.Serial}\r\n{biz.GetErrorsAsString()}"; - log.LogError(err); - throw new System.Exception(err); - } -} + //This seems wrong to do in a loop but is 4 times faster this way ?!? + using (AyContext ct = ServiceProviderProvider.DBContext) + { + PMBiz biz = PMBiz.GetBiz(ct); + var NewObject = await biz.PMCreateAsync(o, false); + TotalSeededPMs++; + if (NewObject == null) + { + var err = $"Seeder::SeedPM error creating {o.Serial}\r\n{biz.GetErrorsAsString()}"; + log.LogError(err); + throw new System.Exception(err); + } + } } } @@ -4079,22 +4083,22 @@ using (AyContext ct = ServiceProviderProvider.DBContext) private long GetRandomUnitForCustomer(long customerId) -{ - var l = CustomerUnits.Where(x => x.Key == customerId).FirstOrDefault();//Fake.Random.Long(1, TotalSeededUnits); - var numUnits = l.Value.Count(); - //because faker values are INCLUSIVE and this is going to be used as an index on an array need to -1 each end of the range - var i = Fake.Random.Int(0, numUnits - 1); - return l.Value[i]; -} + { + var l = CustomerUnits.Where(x => x.Key == customerId).FirstOrDefault();//Fake.Random.Long(1, TotalSeededUnits); + var numUnits = l.Value.Count(); + //because faker values are INCLUSIVE and this is going to be used as an index on an array need to -1 each end of the range + var i = Fake.Random.Int(0, numUnits - 1); + return l.Value[i]; + } -private long GetRandomCustomerId() -{ - //return any random customer except for the shadow unit one - long ret = KnownCustomerForShadownUnitsId; - while (ret == KnownCustomerForShadownUnitsId) - ret = Fake.Random.Long(1, TotalSeededCustomers); - return ret; -} + private long GetRandomCustomerId() + { + //return any random customer except for the shadow unit one + long ret = KnownCustomerForShadownUnitsId; + while (ret == KnownCustomerForShadownUnitsId) + ret = Fake.Random.Long(1, TotalSeededCustomers); + return ret; + } //////////////////////////////////////////////////////////////////////////////////////////////////