示例#1
0
        public ActionResult Index(Guid leadId)
        {
            Lead         lead;
            IList <Deal> deals;

            using (var transactionScope = new TransactionScope())
            {
                lead  = _leadRepository.GetById(leadId);
                deals = _dealRepository.GetByLeadId(leadId);
                transactionScope.Complete();
            }

            var employees = _employeeService.GetByIds(deals.Select(deal => deal.MadeByConsultantId).ToArray());

            var viewModel = new IndexDealsViewModel
            {
                LeadId   = leadId,
                LeadName = lead.Name,
                Records  = deals.Select(deal => new IndexDealsRecordViewModel
                {
                    Id = deal.Id.Value,
                    MadeByConsultant =
                        employees.Single(
                            employee =>
                            employee.Id.Value ==
                            deal.MadeByConsultantId).FullName,
                    Value = deal.Value
                }).ToList()
            };

            return(View(viewModel));
        }