public CostBatch ChangeQuantity(TECCost cost, int deltaQuantity) { bool containsItem = costDictionary.ContainsKey(cost.Guid); if (containsItem) { CostSummaryItem item = costDictionary[cost.Guid]; if (item.Quantity + deltaQuantity < 0) { logger.Error("Cannot remove more quantity than exists in CostSummaryItem. Removing all that exists." + "Cost: {0}", cost.Name); deltaQuantity = item.Quantity; } CostBatch delta = item.AddQuantity(deltaQuantity); if (cost is TECMisc) { if (cost.Type == CostType.TEC) { MiscTECCostTotal += delta.GetCost(CostType.TEC); MiscTECLaborTotal += delta.GetLabor(CostType.TEC); } else if (cost.Type == CostType.Electrical) { MiscElecCostTotal += delta.GetCost(CostType.Electrical); MiscElecLaborTotal += delta.GetLabor(CostType.Electrical); } } else { if (cost.Type == CostType.TEC) { AssocTECCostTotal += delta.GetCost(CostType.TEC); AssocTECLaborTotal += delta.GetLabor(CostType.TEC); } else if (cost.Type == CostType.Electrical) { AssocElecCostTotal += delta.GetCost(CostType.Electrical); AssocElecLaborTotal += delta.GetLabor(CostType.Electrical); } } return(delta); } else { logger.Error("Cost not found. Cannot change quantity. Cost: {0}", cost.Name); return(new CostBatch()); } }
public CostBatch UpdateCost(TECCost cost) { bool containsItem = costDictionary.ContainsKey(cost.Guid); if (containsItem) { CostSummaryItem item = costDictionary[cost.Guid]; CostBatch delta = item.Refresh(); if (cost is TECMisc) { if (cost.Type == CostType.TEC) { MiscTECCostTotal += delta.GetCost(CostType.TEC); MiscTECLaborTotal += delta.GetLabor(CostType.TEC); } else if (cost.Type == CostType.Electrical) { MiscElecCostTotal += delta.GetCost(CostType.Electrical); MiscElecLaborTotal += delta.GetLabor(CostType.Electrical); } } else { if (cost.Type == CostType.TEC) { AssocTECCostTotal += delta.GetCost(CostType.TEC); AssocTECLaborTotal += delta.GetLabor(CostType.TEC); } else if (cost.Type == CostType.Electrical) { AssocElecCostTotal += delta.GetCost(CostType.Electrical); AssocElecLaborTotal += delta.GetLabor(CostType.Electrical); } } return(delta); } else { logger.Error("Cost not found, cannot update. Cost: {0}", cost.Name); return(new CostBatch()); } }