Ejemplo n.º 1
0
        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());
            }
        }