public static ILinksWrapper Execute <TReadModel>
        (
            TReadModel queryResult,
            HttpContext httpContext,
            LinkGenerator generator
        )
        {
            switch (queryResult)
            {
            case FinancierDetail:
                var employeeDetailLinks = new LinksWrapper <FinancierDetail>
                {
                    Value = queryResult as FinancierDetail,
                    Links = FinancierLinkGenerator.CreateLinks(httpContext, generator, (queryResult as FinancierDetail).FinancierId)
                };

                return(employeeDetailLinks);

            case FinancierAddressDetail:
                var addressDetailLinks = new LinksWrapper <FinancierAddressDetail>
                {
                    Value = queryResult as FinancierAddressDetail,
                    Links = FinancierAddressLinkGenerator.CreateLinks(httpContext, generator, (queryResult as FinancierAddressDetail).AddressId)
                };

                return(addressDetailLinks);

            case FinancierContactDetail:
                var contactDetailLinks = new LinksWrapper <FinancierContactDetail>
                {
                    Value = queryResult as FinancierContactDetail,
                    Links = FinancierContactLinkGenerator.CreateLinks(httpContext, generator, (queryResult as FinancierContactDetail).PersonId)
                };

                return(contactDetailLinks);

            default:
                throw new ArgumentException("Unknown ReadModel", nameof(queryResult));
            }

            throw new NotImplementedException();
        }
Esempio n. 2
0
        public static ILinksWrapper Execute <TReadModel>
        (
            PagedList <TReadModel> queryResult,
            HttpContext httpContext,
            LinkGenerator generator
        )
        {
            switch (queryResult)
            {
            case PagedList <FinancierListItem> :
                LinksWrapperList <FinancierListItem> linksWrappers = new LinksWrapperList <FinancierListItem>();
                var Employees = queryResult.ReadModels as IEnumerable <FinancierListItem>;

                foreach (var listItem in Employees)
                {
                    var links = FinancierLinkGenerator.CreateLinks(httpContext, generator, listItem.FinancierId);


                    linksWrappers.Values.Add
                    (
                        new LinksWrapper <FinancierListItem>
                    {
                        Value = listItem,
                        Links = links
                    }
                    );
                }

                return(linksWrappers);

            case PagedList <FinancierAddressListItem> :
                LinksWrapperList <FinancierAddressListItem> addressLinksWrappers = new LinksWrapperList <FinancierAddressListItem>();
                var financierAddresses = queryResult.ReadModels as IEnumerable <FinancierAddressListItem>;

                foreach (var listItem in financierAddresses)
                {
                    var links = FinancierAddressLinkGenerator.CreateLinks(httpContext, generator, listItem.AddressId);

                    addressLinksWrappers.Values.Add
                    (
                        new LinksWrapper <FinancierAddressListItem>
                    {
                        Value = listItem,
                        Links = links
                    }
                    );
                }

                return(addressLinksWrappers);

            case PagedList <FinancierContactListItem> :
                LinksWrapperList <FinancierContactListItem> contactLinksWrappers = new LinksWrapperList <FinancierContactListItem>();
                var EmployeeContacts = queryResult.ReadModels as IEnumerable <FinancierContactListItem>;

                foreach (var listItem in EmployeeContacts)
                {
                    var links = FinancierContactLinkGenerator.CreateLinks(httpContext, generator, listItem.PersonId);

                    contactLinksWrappers.Values.Add
                    (
                        new LinksWrapper <FinancierContactListItem>
                    {
                        Value = listItem,
                        Links = links
                    }
                    );
                }

                return(contactLinksWrappers);

            default:
                throw new ArgumentException("Unknown ReadModel", nameof(queryResult));
            }
        }