Exemplo n.º 1
0
        public async Task <ResultWrapper <GetRegionCitiesOutput> > Handle(GetRegionCitiesQuery request, CancellationToken cancellationToken)
        {
            ResultWrapper <GetRegionCitiesOutput> result = new ResultWrapper <GetRegionCitiesOutput>();

            var tDataList = await _dbContext.TRegionCity
                            .Include(x => x.TUsers)
                            .Where(x => request.TRegionStateId == x.TRegionStateId)
                            .ToListAsync();

            var list = tDataList.Select(x => new PublicListItem()
            {
                Enabled  = x.Enabled,
                Selected = x.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 GetRegionCitiesOutput()
            {
                list = list
            };

            return(result);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetRegionCities(int regionStateId, int userId = 0)
        {
            GetRegionCitiesQuery model = new GetRegionCitiesQuery()
            {
                userId         = userId,
                TRegionStateId = regionStateId
            };
            ResultWrapper <GetRegionCitiesOutput> result = new ResultWrapper <GetRegionCitiesOutput>();

            result = await _mediator.Send(model);

            return(Ok(result));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetRegionCities(int regionStateId)
        {
            FirebaseUser         user  = HttpContext.GetFirebaseUser();
            GetRegionCitiesQuery model = new GetRegionCitiesQuery()
            {
                firebaseId     = user.UserId,
                TRegionStateId = regionStateId
            };
            ResultWrapper <GetRegionCitiesOutput> result = new ResultWrapper <GetRegionCitiesOutput>();

            result = await _mediator.Send(model);

            return(Ok(result));
        }