Beispiel #1
0
        private async Task <PostServiceViewModel> MapViewModel(
            Service serv, AppUser user, Provider provider)
        {
            var query = await _serviceRepository.FindAllAsync();

            var providerService = await _providerServiceRepository.FindAllAsync();

            var userService = await _userServiceRepository.FindAllAsync();

            var providers = await _providerRepository.FindAllAsync();


            var getTag = await _tagRepository.FindAllAsync();

            var getUserTag = await _tagServiceRepository.FindAllAsync(x => x.ServiceId == serv.Id);

            var getListTag = (from tag in getTag.ToList()
                              join serviceTag in getUserTag.ToList()
                              on tag.Id equals serviceTag.TagId
                              select new
            {
                tag.TagName
            }).ToList();

            var getImage = await _imageRepository.FindAllAsync(x => x.ServiceId == serv.Id);

            PostServiceViewModel postServiceView = new PostServiceViewModel();

            postServiceView.Id         = serv.Id.ToString();
            postServiceView.listImages = getImage.Select(x => new PostServiceImageViewModel
            {
                Path    = x.Path,
                ImageId = x.Id
            }).ToList();
            postServiceView.PriceOfService = serv.PriceOfService;
            postServiceView.CategoryName   = _getByIDCategoryServiceQuery.ExecuteAsync(serv.CategoryId).Result.CategoryName;
            postServiceView.ServiceName    = serv.ServiceName;
            postServiceView.Status         = serv.Status;
            postServiceView.tagofServices  = getListTag.Select(x => new TagofServiceViewModel
            {
                TagName = x.TagName
            }).ToList();
            postServiceView.Description = serv.Description;
            postServiceView.ProviderId  = _getProviderInformationQuery.ExecuteAsync(serv.Id, query, providers, providerService).idProvider
                                          == "" ? _getUserInformationQuery.ExecuteAsync(serv.Id, query, userService) :
                                          _getProviderInformationQuery.ExecuteAsync(serv.Id, query, providers, providerService).idProvider;
            postServiceView.CategoryId = serv.CategoryId;
            postServiceView.Author     =
                _getProviderInformationQuery.ExecuteAsync(serv.Id, query, providers, providerService).NameProvider
                == "" ? _getUserInformationQuery.ExecuteAsync(serv.Id, query, userService) :
                _getProviderInformationQuery.ExecuteAsync(serv.Id, query, providers, providerService).NameProvider;
            return(postServiceView);
        }
        public async Task <IActionResult> GetAllFillter(int id)
        {
            var model = await _getByIdCategoryService.ExecuteAsync(id);

            return(new OkObjectResult(model));
        }