Example #1
0
        public async Task <IActionResult> GetBodyTypes()
        {
            FirebaseUser         user  = HttpContext.GetFirebaseUser();
            GetAllBodyTypesQuery model = new GetAllBodyTypesQuery()
            {
                firebaseId = user.UserId
            };
            ResultWrapper <GetAllBodyTypesOutput> result = new ResultWrapper <GetAllBodyTypesOutput>();

            result = await _mediator.Send(model);

            return(Ok(result));
        }
        public async Task <ResultWrapper <GetAllBodyTypesOutput> > Handle(GetAllBodyTypesQuery request, CancellationToken cancellationToken)
        {
            ResultWrapper <GetAllBodyTypesOutput> result = new ResultWrapper <GetAllBodyTypesOutput>();

            var tDataList = await _dbContext.TBodyType.Include(x => x.TUsers).ToListAsync();

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

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

            return(result);
        }