public async Task <ResultWrapper <GetRegionStatesOutput> > Handle(GetRegionStatesQuery request, CancellationToken cancellationToken)
        {
            ResultWrapper <GetRegionStatesOutput> result = new ResultWrapper <GetRegionStatesOutput>();

            var tDataList = await _dbContext.TRegionState
                            .Include(x => x.TRegionCities).ThenInclude(x => x.TUsers)
                            .Where(x => request.TRegionCountryId == x.TRegionCountryId)
                            .ToListAsync();

            var list = tDataList.Select(x => new PublicListItem()
            {
                Enabled  = x.Enabled,
                Selected = x.TRegionCities.SelectMany(z => z.TUsers)
                           .Any(z => (z.FireBaseId == request.firebaseId) || (z.Id == request.userId)),
                Text  = x.Title,
                Value = x.Id.ToString(),
                Image = x.Image.JoinWithCDNAddress()
            })
                       .ToList();

            result.Status = true;
            result.Result = new GetRegionStatesOutput()
            {
                list = list
            };

            return(result);
        }
Beispiel #2
0
        public async Task <IActionResult> GetRegionStates(int regionCountryId, int userId = 0)
        {
            GetRegionStatesQuery model = new GetRegionStatesQuery()
            {
                userId           = userId,
                TRegionCountryId = regionCountryId
            };
            ResultWrapper <GetRegionStatesOutput> result = new ResultWrapper <GetRegionStatesOutput>();

            result = await _mediator.Send(model);

            return(Ok(result));
        }
Beispiel #3
0
        public async Task <IActionResult> GetRegionStates(int regionCountryId)
        {
            FirebaseUser         user  = HttpContext.GetFirebaseUser();
            GetRegionStatesQuery model = new GetRegionStatesQuery()
            {
                firebaseId       = user.UserId,
                TRegionCountryId = regionCountryId
            };
            ResultWrapper <GetRegionStatesOutput> result = new ResultWrapper <GetRegionStatesOutput>();

            result = await _mediator.Send(model);

            return(Ok(result));
        }