/// <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); }
/// <summary> /// /// </summary> public async Task <List <State> > handleAsync(StateFindFromCacheMsg request) { var result = await searchState.findAll(request.filter); return(result); }