Exemplo n.º 1
0
        // GET: Client/Details/5
        public ActionResult Details(int?id)
        {
            if (id.HasValue == false)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var clientDetailModel = Uow.Clients.GetAll()
                                    .Where(c => c.Id == id)
                                    .ProjectTo <ClientDetailModel>()
                                    .FirstOrDefault();

            if (clientDetailModel == null)
            {
                return(HttpNotFound());
            }

            if (clientDetailModel.IsOrganization)
            {
                clientDetailModel.ClientName = clientDetailModel.OrganizationName;
            }

            var clientPoliciesList = Uow.Policies.GetAll()
                                     .Where(p => p.ClientId == id)
                                     .ProjectTo <ClientPoliciesListModel>()
                                     .ToList();

            clientDetailModel.ClientPoliciesList = clientPoliciesList;

            var clientClaimsList = Uow.Policies.GetAll()
                                   .Where(p => p.ClientId == id)
                                   .SelectMany(p => p.Claims)
                                   .ProjectTo <ClientClaimsListModel>()
                                   .ToList();

            clientDetailModel.ClientClaimsList = clientClaimsList;

            var clientOffersList = Uow.Offers.GetAll()
                                   .Where(p => p.ClientId == id)
                                   .ProjectTo <ClientOffersListModel>()
                                   .ToList();

            clientDetailModel.ClientOffersList = clientOffersList;

            var offerStatuses = ListProviderSvc.GetOfferStatuses();

            clientDetailModel.OfferStatuses = offerStatuses;

            return(View(clientDetailModel));
        }