public async Task <ApiResponse <List <AppTemplateConversionUnitGenericGetDto> > > GetAllTemplateByUnitsInput(AppTemplateConversionUnitQueryFilter filter) { Metadata metadata = new Metadata { IsValid = true, Message = "" }; List <AppTemplateConversionUnitGenericGetDto> resultDto = new List <AppTemplateConversionUnitGenericGetDto>(); ApiResponse <List <AppTemplateConversionUnitGenericGetDto> > response = new ApiResponse <List <AppTemplateConversionUnitGenericGetDto> >(resultDto); try { var template = await _unitOfWork.AppTemplateConversionUnitRepository.GetAllTemplateByUnitsInput(filter.AppUnitIdSince, filter.AppUnitIdUntil); template = template.OrderBy(x => x.OrderCalculate).ToList(); resultDto = _mapper.Map <List <AppTemplateConversionUnitGenericGetDto> >(template); foreach (var item in resultDto) { AppUnits AppUnitsFind = await _appUnitsService.GetById(item.AppUnitIdSince); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); item.AppUnitIdSinceGetDto = appUnitsGetDto; } AppUnitsFind = await _appUnitsService.GetById(item.AppUnitIdUntil); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); item.AppUnitIdUntilGetDto = appUnitsGetDto; } AppVariables AppVariablesFind = await _appVariablesService.GetById(item.AppVariableId); if (AppVariablesFind != null) { AppVariablesGetDto appVariablesGetDto = _mapper.Map <AppVariablesGetDto>(AppVariablesFind); item.AppVariablesGetDto = appVariablesGetDto; } } response.Meta = metadata; response.Data = resultDto; return(response); } catch (Exception ex) { metadata.IsValid = false; metadata.Message = ex.InnerException.Message; response.Meta = metadata; response.Data = null; return(response); } }
public async Task <ApiResponse <List <AppIngredientsGetDto> > > GetAllFilter(AppIngredientsQueryFilter filter) { filter.PageNumber = filter.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filter.PageNumber; filter.PageSize = filter.PageSize == 0 ? _paginationOptions.DefaultPageSize : filter.PageSize; List <AppIngredientsGetDto> resultDto = new List <AppIngredientsGetDto>(); Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <List <AppIngredientsGetDto> > response = new ApiResponse <List <AppIngredientsGetDto> >(resultDto); try { List <AppIngredients> appIngredients = await _unitOfWork.AppIngredientsRepository.GetAllFilter(filter); if (appIngredients != null) { List <AppIngredientsGetDto> appIngredientsDto = _mapper.Map <List <AppIngredientsGetDto> >(appIngredients); foreach (AppIngredientsGetDto item in appIngredientsDto) { AppUnits AppUnitsFind = await _appUnitsService.GetById(item.AppUnitId); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); item.AppUnitsGetDto = appUnitsGetDto; } MtrTipoMoneda MtrTipoMonedaFind = await _mtrTipoMonedaService.GetById((long)item.PrymaryMtrMonedaId); if (MtrTipoMonedaFind != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(MtrTipoMonedaFind); item.PrymaryMtrMonedaDto = mtrTipoMonedaDto; } MtrTipoMonedaFind = await _mtrTipoMonedaService.GetById((long)item.SecundaryMtrMonedaId); if (MtrTipoMonedaFind != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(MtrTipoMonedaFind); item.SecundaryMtrMonedaDto = mtrTipoMonedaDto; } } response.Data = appIngredientsDto; response.Meta = metadata; return(response); } else { metadata.IsValid = true; metadata.Message = "No Data...."; response.Data = null; response.Meta = metadata; return(response); } } catch (Exception ex) { metadata.IsValid = false; metadata.Message = ex.InnerException.Message; response.Data = null; response.Meta = metadata; return(response); } }
public async Task <ApiResponse <List <AppProductsGetDto> > > GetAll(AppProdutsQueryFilter filters) { filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber; filters.PageSize = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize; List <AppProductsGetDto> resultDto = new List <AppProductsGetDto>(); Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <List <AppProductsGetDto> > response = new ApiResponse <List <AppProductsGetDto> >(resultDto); try { var appProducts = await _unitOfWork.AppProductsRepository.GetAllFilter(filters); if (appProducts != null) { List <AppProductsGetDto> appProductsDto = _mapper.Map <List <AppProductsGetDto> >(appProducts); foreach (var item in appProductsDto) { if (item.UrlImage == "" || item.UrlImage == null) { item.Link = _paginationOptions.UrlGetFiles + "NoImage.png"; } else { item.Link = _paginationOptions.UrlGetFiles + item.UrlImage; } AppUnits AppUnitsFind = await _appUnitsService.GetById((int)item.AppUnitsId); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); item.AppUnitsGetDto = appUnitsGetDto; } AppUnitsFind = await _appUnitsService.GetById((int)item.ProductionUnitId); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); item.ProductionUnitGetDto = appUnitsGetDto; } MtrTipoMoneda MtrTipoMonedaFind = await _mtrTipoMonedaService.GetById((long)item.PrymaryMtrMonedaId); if (MtrTipoMonedaFind != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(MtrTipoMonedaFind); item.PrymaryMtrMonedaGetDto = mtrTipoMonedaDto; } MtrTipoMonedaFind = await _mtrTipoMonedaService.GetById((long)item.SecundaryMtrMonedaId); if (MtrTipoMonedaFind != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(MtrTipoMonedaFind); item.SecundaryMtrMonedaGetDto = mtrTipoMonedaDto; } AppSubCategory AppSubCategoryFind = await _appSubCategoryService.GetById((int)item.AppSubCategoryId); if (AppSubCategoryFind != null) { AppSubCategoryGetDto appSubCategoryGetDto = _mapper.Map <AppSubCategoryGetDto>(AppSubCategoryFind); item.AppSubCategoryGetDto = appSubCategoryGetDto; } } response.Data = appProductsDto; response.Meta = metadata; return(response); } else { metadata.IsValid = true; metadata.Message = "No Data...."; response.Data = null; response.Meta = metadata; return(response); } } catch (Exception ex) { metadata.IsValid = false; metadata.Message = ex.InnerException.Message; response.Data = null; response.Meta = metadata; return(response); } }