コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        public async Task <List <StateResponse> > findAll(StateRequest filter)
        {
            var response = new List <StateResponse>();

            var filterState = new StateFilter();

            filterState.ids = new int[] { filter.id };
            filterState.setQuery(StateProjections.basicOne.Key);
            var msg = new StateFindAllNoPageMsg(filterState);

            var responseQuery = await searchState.handleAsync(msg);

            if (!responseQuery.Any())
            {
                return(response);
            }

            responseQuery.ForEach(x => {
                var StateResponse = new StateResponse();
                StateResponse.fromEntity(x);
                response.Add(StateResponse);
            });

            return(response);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        public async Task <Response <Address> > handleAsync(AddressCreatorCommand model)
        {
            var response = new Response <Address>();

            var filter = new StateFilter();

            filter.setQuery(StateProjections.basicOne.Key);

            var msg    = new StateFindFromCacheMsg(filter);
            var result = await searchState.handleAsync(msg);

            using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) {
                try {
                    foreach (var item in model.request.listRequest)
                    {
                        var idState = result.Where(x => x.initials == item.initialsState).Select(x => x.id).FirstOrDefault();

                        if (idState == 0)
                        {
                            response.error = true;
                            return(response);
                        }

                        var form = new AddressForm(item.name, idState);

                        var entity = await creator.create(form);

                        response.results.Add(entity);
                    }

                    transaction.Complete();
                }
                catch (System.Exception) {
                    response.error = true;
                }
            }

            return(response);
        }