Пример #1
0
        private IQueryable <OrderViewModel> GetOrders(Guid?orderRsn = null, int?orderId = null)
        {
            // Define Query
            ICollectionResultQuery <OrderQueryStrategy, OrderEntity> query = QueryFactory.CreateNewCollectionResultQuery <OrderQueryStrategy, OrderEntity>();

            // We don't want entities we've marked as deleted.
            query.QueryStrategy.WithNoDeletedOrders();

            // If an orderRsn is provided, query on that
            if (orderRsn != null)
            {
                query.QueryStrategy.WithRsn(orderRsn.Value);
            }
            // If an orderId is provided, query on that
            if (orderId != null)
            {
                query.QueryStrategy.WithOrderId(orderId.Value);
            }

            // Retrieve Data
            query = OrderRepository.Retrieve(query);
            IEnumerable <OrderEntity> queryResults = query.Result;

            IQueryable <OrderViewModel> orders = queryResults
                                                 .Select(x => (OrderViewModel)x)
                                                 .AsQueryable();

            return(orders);
        }
Пример #2
0
        /// <summary>
        /// Get all <see cref="MessageEntity">messages</see> for the provided conversation.
        /// </summary>
        public virtual IServiceResponseWithResultData <IEnumerable <MessageEntity> > GetMessages(IServiceRequestWithData <Guid, ConversationParameters> serviceRequest)
        {
            AuthenticationTokenHelper.SetAuthenticationToken(serviceRequest.AuthenticationToken);
            CorrelationIdHelper.SetCorrelationId(serviceRequest.CorrelationId);

            Guid conversationRsn = serviceRequest.Data.ConversationRsn;

            // Define Query
            ICollectionResultQuery <MessageQueryStrategy, MessageEntity> query = QueryFactory.CreateNewCollectionResultQuery <MessageQueryStrategy, MessageEntity>();

            query.QueryStrategy.WithConversationRsn(conversationRsn);
            query.QueryStrategy.OrderByDatePosted();

            // Retrieve Data
            query = MessageRepository.Retrieve(query);
            IEnumerable <MessageEntity> queryResults = query.Result.ToList();

            var responseData = new ServiceResponseWithResultData <IEnumerable <MessageEntity> >
            {
                State      = ServiceResponseStateType.Succeeded,
                ResultData = queryResults
            };

            // Complete the response
            ServiceResponseWithResultData <IEnumerable <MessageEntity> > response = CompleteResponse(responseData);

            if (!queryResults.Any())
            {
                response.State = ServiceResponseStateType.EntityNotFound;
            }

            return(response);
        }
Пример #3
0
        public virtual HttpResponseMessage <ServiceResponseWithResultData <IEnumerable <MessageEntity> > > GetMessages(Guid conversationRsn)
        {
            // Define Query
            ICollectionResultQuery <MessageQueryStrategy, MessageEntity> query = QueryFactory.CreateNewCollectionResultQuery <MessageQueryStrategy, MessageEntity>();

            query.QueryStrategy.WithConversationRsn(conversationRsn);
            query.QueryStrategy.OrderByDatePosted();

            // Retrieve Data
            query = MessageRepository.Retrieve(query);
            IEnumerable <MessageEntity> queryResults = query.Result.ToList();

            var responseData = new ServiceResponseWithResultData <IEnumerable <MessageEntity> >
            {
                State      = ServiceResponseStateType.Succeeded,
                ResultData = queryResults
            };

            // Complete the response
            HttpResponseMessage <ServiceResponseWithResultData <IEnumerable <MessageEntity> > > response = CompleteResponseWithData(responseData);

            if (!queryResults.Any())
            {
                response.StatusCode = HttpStatusCode.NotFound;
            }

            return(response);
        }
Пример #4
0
        partial void OnGetAll(IServiceRequestWithData <Cqrs.Authentication.ISingleSignOnToken, UserServiceGetAllParameters> serviceRequest, ref IServiceResponseWithResultData <IEnumerable <Entities.UserEntity> > results)
        {
            // Define Query
            ICollectionResultQuery <UserQueryStrategy, Entities.UserEntity> query = QueryFactory.CreateNewCollectionResultQuery <UserQueryStrategy, Entities.UserEntity>();

            // Retrieve Data, but remember if no items exist, the value is null
            query = UserRepository.Retrieve(query);
            IEnumerable <Entities.UserEntity> inventoryItems = query.Result;

            results = new ServiceResponseWithResultData <IEnumerable <Entities.UserEntity> >(inventoryItems);
        }
Пример #5
0
        partial void OnGetAllOrders(IServiceRequestWithData <Cqrs.Authentication.ISingleSignOnToken, OrderServiceGetAllOrdersParameters> serviceRequest, ref IServiceResponseWithResultData <IEnumerable <OrderEntity> > results)
        {
            // Define Query
            ICollectionResultQuery <OrderQueryStrategy, OrderEntity> query = QueryFactory.CreateNewCollectionResultQuery <OrderQueryStrategy, OrderEntity>();

            // Retrieve Data
            query = OrderRepository.Retrieve(query);
            IEnumerable <OrderEntity> orders = query.Result;

            results = new ServiceResponseWithResultData <IEnumerable <OrderEntity> >
            {
                State      = ServiceResponseStateType.Succeeded,
                ResultData = orders
            };
        }
Пример #6
0
        /// <summary>
        /// Get all <see cref="ConversationSummaryEntity">conversations</see>.
        /// </summary>
        public virtual IServiceResponseWithResultData <IEnumerable <ConversationSummaryEntity> > Get(IServiceRequest <Guid> serviceRequest)
        {
            AuthenticationTokenHelper.SetAuthenticationToken(serviceRequest.AuthenticationToken);
            CorrelationIdHelper.SetCorrelationId(serviceRequest.CorrelationId);

            // Define Query
            ICollectionResultQuery <ConversationSummaryQueryStrategy, ConversationSummaryEntity> query = QueryFactory.CreateNewCollectionResultQuery <ConversationSummaryQueryStrategy, ConversationSummaryEntity>();

            query.QueryStrategy.WithNoDeletedConversations();

            // Retrieve Data
            query = ConversationSummaryRepository.Retrieve(query);
            IEnumerable <ConversationSummaryEntity> queryResults = query.Result;

            var responseData = new ServiceResponseWithResultData <IEnumerable <ConversationSummaryEntity> >
            {
                State      = ServiceResponseStateType.Succeeded,
                ResultData = queryResults
            };

            // Complete the response
            ServiceResponseWithResultData <IEnumerable <ConversationSummaryEntity> > response = CompleteResponse(responseData);

            return(response);
        }
Пример #7
0
        public virtual HttpResponseMessage <ServiceResponseWithResultData <IEnumerable <ConversationSummaryEntity> > > Get()
        {
            // Define Query
            ICollectionResultQuery <ConversationSummaryQueryStrategy, ConversationSummaryEntity> query = QueryFactory.CreateNewCollectionResultQuery <ConversationSummaryQueryStrategy, ConversationSummaryEntity>();

            query.QueryStrategy.WithNoDeletedConversations();

            // Retrieve Data
            query = ConversationSummaryRepository.Retrieve(query);
            IEnumerable <ConversationSummaryEntity> queryResults = query.Result;

            var responseData = new ServiceResponseWithResultData <IEnumerable <ConversationSummaryEntity> >
            {
                State      = ServiceResponseStateType.Succeeded,
                ResultData = queryResults
            };

            // Complete the response
            HttpResponseMessage <ServiceResponseWithResultData <IEnumerable <ConversationSummaryEntity> > > response = CompleteResponseWithData(responseData);

            return(response);
        }