コード例 #1
0
ファイル: BidController.cs プロジェクト: JoshIBrown/BidChuck
 public ActionResult ComposeSV(SVBidEditModel viewModel)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
ファイル: BidController.cs プロジェクト: JoshIBrown/BidChuck
        public ActionResult ComposeSV(int projectId)
        {
            int companyId = _service.GetUserProfile(_security.GetUserId(User.Identity.Name)).CompanyId;

            // get invitations company has accepted
            List<Invitation> invitations = _service.GetInvitesCompanyHasAccepted(projectId, companyId).ToList();

            SVBidEditModel viewModel = new SVBidEditModel();

            BCModel.Projects.Project theProject = _service.GetProject(projectId);
            viewModel.ProjectId = projectId;
            viewModel.ProjectName = theProject.Title;

            // get list of base bids if they've been saved
            IEnumerable<BaseBid> baseBids = _service.GetCompanyBaseBidsForProject(companyId, projectId);

            // get available scopes
            IEnumerable<Scope> companyScopes = _service.GetCompanyScopesForProject(projectId, companyId).OrderBy(o => o.CsiNumber);

            // FIXME: need to account for scope changes after a draft is saved
            // if there isn't a saved draft
            if (baseBids == null || baseBids.Count() == 0)
            {
                viewModel.BaseBids = companyScopes
                    .OrderBy(o => o.CsiNumber)
                    .Select(s => new BaseBidEditItem
                    {
                        ScopeDescription = s.CsiNumber + " " + s.Description,
                        ScopeId = s.Id
                    }).ToList();
            }
            else
            {
                viewModel.BaseBids = baseBids
                    .OrderBy(b => b.Scope.CsiNumber)
                    .Select(b => new BaseBidEditItem
                {
                    ScopeDescription = b.Scope.CsiNumber + " " + b.Scope.Description,
                    ScopeId = b.ScopeId,
                    Amount = b.Amount
                }).ToList();
            }

            // create bid packages
            List<SVBidPackageItem> bidPackages = new List<SVBidPackageItem>();
            SVBidPackageItem bidPackage;

            // loop through bid packages
            for (int b = 0; b < invitations.Count; b++)
            {
                bidPackage = new SVBidPackageItem();
                bidPackage.BidPacakgeId = invitations[b].BidPackageId;
                bidPackage.CompanyName = invitations[b].BidPackage.CreatedBy.CompanyName;

                // get computed bids
                bidPackage.ComputedBids = _service.GetCompanyComputedBidsForBidPackage(bidPackage.BidPacakgeId, companyId)
                    .OrderBy(o => o.Scope.CsiNumber)
                    .Select(c => new ComputedBidEditItem { RiskFactor = c.RiskFactor.HasValue ? c.RiskFactor.Value : 0.00m, ScopeId = c.ScopeId })
                    .ToList();

                // if no prior computed bids
                if (bidPackage.ComputedBids.Count == 0 && companyScopes.Count() > 0)
                {
                    // get bid package scopes, and assemble empty computed bids
                    bidPackage.ComputedBids = _service.GetBidPackageScopes(bidPackage.BidPacakgeId)
                        .OrderBy(s => s.CsiNumber)
                        .Select(s => new ComputedBidEditItem { ScopeId = s.Id })
                        .ToList();
                }

                bidPackages.Add(bidPackage);
            }
            viewModel.BidPackages = bidPackages;

            return View(viewModel);
        }