예제 #1
0
 private void DeleteCost(ProposalFixedCost cost)
 {
     FixedCosts.Remove(cost);
     Proposal.FixedCosts.Remove(cost);
 }
        private void UpdateProposalFixedCosts(ScrumFactoryEntities context, Proposal proposal, Proposal oldProposal)
        {
            // make sure no proposal has null collections
            if (proposal.FixedCosts == null)
                proposal.FixedCosts = new List<ProposalFixedCost>();
            if (oldProposal.FixedCosts == null)
                oldProposal.FixedCosts = new List<ProposalFixedCost>();

            ProposalFixedCost[] newCosts = new ProposalFixedCost[0];
            newCosts = proposal.FixedCosts.Where(i => !oldProposal.FixedCosts.Any(oi => oi.ProposalFixedCostUId == i.ProposalFixedCostUId)).ToArray();

            ProposalFixedCost[] deletedCosts = new ProposalFixedCost[0];
            deletedCosts = oldProposal.FixedCosts.Where(oi => !proposal.FixedCosts.Any(i => i.ProposalFixedCostUId == oi.ProposalFixedCostUId)).ToArray();

            ProposalFixedCost[] updatedCosts = new ProposalFixedCost[0];
            updatedCosts = proposal.FixedCosts.Where(oi => oldProposal.FixedCosts.Any(i => i.ProposalFixedCostUId == oi.ProposalFixedCostUId)).ToArray();

            // add/update/delete proposal items
            foreach (ProposalFixedCost cost in newCosts)
                context.ProposalFixedCosts.AddObject(cost);
            foreach (ProposalFixedCost cost in deletedCosts)
                context.ProposalFixedCosts.DeleteObject(cost);
            foreach (ProposalFixedCost cost in updatedCosts)
                context.ApplyCurrentValues<ProposalFixedCost>("ProposalFixedCosts", cost);
        }
예제 #3
0
 private void AddFixedCost()
 {
     ProposalFixedCost cost = new ProposalFixedCost();
     cost.ProposalFixedCostUId = Guid.NewGuid().ToString();
     cost.RepassToClient = true;
     cost.ProposalUId = Proposal.ProposalUId;
     cost.CostDescription = Properties.Resources.New_cost;
     FixedCosts.Add(cost);
     Proposal.FixedCosts.Add(cost);
     FixedCostPrice = Proposal.CalcFixedCosts();
 }