示例#1
0
        public Proposal AddProposal(string projectUId, Proposal newProposal)
        {
            // verifies permission
            authorizationService.VerifyPermissionAtProject(projectUId, PermissionSets.SCRUM_MASTER);
            authorizationService.VerifyCanSeeProposalValues();

            // get proposals project
            Project project = projectsService.GetProject(projectUId);

            // crete new proposal
            newProposal.CreateDate   = DateTime.Now;
            newProposal.TemplateName = "default";

            // sets proposal template
            String[] templates = GetProposalTemplates();
            if (templates.Length > 0)
            {
                if (!templates.Contains("default"))
                {
                    newProposal.TemplateName = templates.OrderBy(t => t).ToArray()[0];
                }
            }


            // create hours costs if not exist at project
            RoleHourCost[] costs = proposalsRepository.GetHourCosts(projectUId);
            if (costs == null || costs.Length == 0)
            {
                // try to find a similar project
                Project similar = projectsService.GetLastSimilarProject(projectUId, true);
                proposalsRepository.CreateHourCosts(project, similar);
            }

            // include all backlog items at the proposal
            newProposal.Items = new List <ProposalItem>();
            ICollection <BacklogItem> projectItems = backlogservice.GetCurrentBacklog(projectUId, (short)BacklogFiltersMode.ALL);

            foreach (BacklogItem item in projectItems)
            {
                newProposal.Items.Add(new ProposalItem()
                {
                    ProposalUId = newProposal.ProposalUId, BacklogItemUId = item.BacklogItemUId, Item = item
                });
            }

            // calcs total value
            newProposal.TotalValue = newProposal.CalcTotalPrice(costs);

            proposalsRepository.SaveProposal(newProposal);

            return(newProposal);
        }
示例#2
0
        public void UpdateHourCosts(string projectUId, RoleHourCost[] hourCosts)
        {
            // verifies permission
            authorizationService.VerifyPermissionAtProject(projectUId, PermissionSets.SCRUM_MASTER);
            authorizationService.VerifyCanSeeProposalValues();

            // save new costs
            proposalsRepository.SaveHourCosts(hourCosts);

            // updates the project proposals with new total price
            ICollection <BacklogItem> backlog   = backlogservice.GetCurrentBacklog(projectUId, (short)BacklogFiltersMode.ALL);
            ICollection <Proposal>    proposals = GetProjectProposals(projectUId);

            foreach (Proposal p in proposals.Where(p => p.ProposalStatus == (short)ProposalStatus.PROPOSAL_WAITING))
            {
                Proposal pWithItems = GetProjectProposal(projectUId, p.ProposalUId);
                pWithItems.SetBacklogItems(backlog);
                pWithItems.TotalValue = pWithItems.CalcTotalPrice(hourCosts);
                proposalsRepository.SaveProposal(pWithItems);
            }
        }
        private void CalcBacklogPrice()
        {
            Proposal proposal = new Proposal();
            proposal.UseCalcPrice = true;

            BacklogPriceStr = Properties.Resources.Calculating;
            executor.StartBackgroundTask<RoleHourCost[]>(() => {
                return proposalsService.GetHourCosts(Project.ProjectUId);
            },
            costs => {
                proposal.Items = new List<ProposalItem>();

                var items = SelectedItems;
                if (items.Count == 0)
                    items = this.Items;
                foreach (var itemVM in items)
                    proposal.Items.Add(new ProposalItem() { ProposalUId = proposal.ProposalUId, BacklogItemUId = itemVM.Item.BacklogItemUId, Item = itemVM.Item });

                // calcs total value
                proposal.TotalValue = proposal.CalcTotalPrice(costs);
                BacklogPriceStr = proposal.TotalValue.ToString("c"); ;
            });
        }
示例#4
0
        public Proposal AddProposal(string projectUId, Proposal newProposal)
        {
            // verifies permission
            authorizationService.VerifyPermissionAtProject(projectUId, PermissionSets.SCRUM_MASTER);
            authorizationService.VerifyCanSeeProposalValues();

            // get proposals project
            Project project = projectsService.GetProject(projectUId);

            // crete new proposal
            newProposal.CreateDate = DateTime.Now;
            newProposal.TemplateName = "default";

            // sets proposal template
            String[] templates = GetProposalTemplates();
            if (templates.Length > 0) {
                if(!templates.Contains("default"))
                    newProposal.TemplateName = templates.OrderBy(t => t).ToArray()[0];
            }

            // create hours costs if not exist at project
            RoleHourCost[] costs = proposalsRepository.GetHourCosts(projectUId);
            if (costs == null || costs.Length == 0) {
                // try to find a similar project
                Project similar = projectsService.GetLastSimilarProject(projectUId, true);
                proposalsRepository.CreateHourCosts(project, similar);
            }

            // include all backlog items at the proposal
            newProposal.Items = new List<ProposalItem>();
            ICollection<BacklogItem> projectItems = backlogservice.GetCurrentBacklog(projectUId, (short) BacklogFiltersMode.ALL);
            foreach (BacklogItem item in projectItems)
                newProposal.Items.Add(new ProposalItem() { ProposalUId = newProposal.ProposalUId, BacklogItemUId = item.BacklogItemUId, Item = item });

            // calcs total value
            newProposal.TotalValue = newProposal.CalcTotalPrice(costs);

            proposalsRepository.SaveProposal(newProposal);

            return newProposal;
        }