Esempio n. 1
0
        public async Task <AppGeneralQuotesGetDto> GetAppGeneralQuotes(AppGeneralQuotesQueryFilter filters)
        {
            filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber;
            filters.PageSize   = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize;


            AppGeneralQuotes quotes = await _unitOfWork.AppGeneralQuotesRepository.GetByCotizacions(filters.Cotizacion);

            if (quotes != null)
            {
                AppGeneralQuotesGetDto appGeneralQuotesGetDto = _mapper.Map <AppGeneralQuotesGetDto>(quotes);

                MtrVendedor mtrVendedor = _unitOfWork.MtrVendedorRepository.GetById(appGeneralQuotesGetDto.IdVendedor);
                if (mtrVendedor != null)
                {
                    MtrVendedorDto mtrVendedorDto = _mapper.Map <MtrVendedorDto>(mtrVendedor);
                    appGeneralQuotesGetDto.MtrVendedorDto = mtrVendedorDto;
                }



                MtrCliente mtrCliente = _unitOfWork.MtrClienteRepository.GetById(appGeneralQuotesGetDto.IdCliente);
                if (mtrCliente != null)
                {
                    MtrClienteDto mtrClienteDto = _mapper.Map <MtrClienteDto>(mtrCliente);
                    appGeneralQuotesGetDto.MtrClienteDto = mtrClienteDto;
                }

                MtrContactos mtrContactos = await _unitOfWork.MtrContactosRepository.GetById(appGeneralQuotesGetDto.IdContacto);

                if (mtrContactos != null)
                {
                    //MtrContactosDto mtrContactosDto = new MtrContactosDto();
                    //mtrContactosDto.IdContacto = mtrContactos.IdContacto;
                    //mtrContactosDto.Cargo = mtrContactos.Email;

                    MtrContactosDto mtrContactosDto = _mapper.Map <MtrContactosDto>(mtrContactos);
                    appGeneralQuotesGetDto.MtrContactosDto = mtrContactosDto;
                }



                MtrDirecciones direccionEntregar = await _unitOfWork.MtrDireccionesRepository.GetById(appGeneralQuotesGetDto.IdDireccionEntregar);

                if (direccionEntregar != null)
                {
                    MtrDireccionesDto direccionEntregarDto = _mapper.Map <MtrDireccionesDto>(direccionEntregar);
                    appGeneralQuotesGetDto.MtrDireccionesEntregarDto = direccionEntregarDto;
                }



                MtrDirecciones direccionFacturar = await _unitOfWork.MtrDireccionesRepository.GetById(appGeneralQuotesGetDto.IdDireccionFacturar);

                if (direccionFacturar != null)
                {
                    MtrDireccionesDto direccionFacturarDto = _mapper.Map <MtrDireccionesDto>(direccionFacturar);
                    appGeneralQuotesGetDto.MtrDireccionesFacturarDto = direccionFacturarDto;
                }

                MtrCondicionPago condicionPago = await _unitOfWork.MtrCondicionPagoRepository.GetById(appGeneralQuotesGetDto.IdCondPago);

                if (condicionPago != null)
                {
                    CondicionPagoDto condicionPagoDto = _mapper.Map <CondicionPagoDto>(condicionPago);
                    appGeneralQuotesGetDto.CondicionPagoDto = condicionPagoDto;
                }

                MtrTipoMoneda mtrTipoMoneda = await _unitOfWork.MtrTipoMonedaRepository.GetById(appGeneralQuotesGetDto.IdMtrTipoMoneda);

                if (mtrTipoMoneda != null)
                {
                    MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(mtrTipoMoneda);
                    appGeneralQuotesGetDto.MtrTipoMonedaDto = mtrTipoMonedaDto;
                }

                var actualizar = await _unitOfWork.AppGeneralQuotesRepository.VerificarStatus(appGeneralQuotesGetDto.Id);

                if (actualizar)
                {
                    await _unitOfWork.SaveChangesAsync();
                }


                AppStatusQuote appStatusQuote = await _unitOfWork.AppStatusQuoteRepository.GetById(appGeneralQuotesGetDto.IdEstatus);

                if (appStatusQuote != null)
                {
                    AppStatusQuoteGetDto appStatusQuoteDto = _mapper.Map <AppStatusQuoteGetDto>(appStatusQuote);
                    appGeneralQuotesGetDto.AppStatusQuoteGetDto = appStatusQuoteDto;
                }

                appGeneralQuotesGetDto.PorcFlete = await GetFleteByIdDireccionEntrega(appGeneralQuotesGetDto.IdDireccionEntregar);


                var permiteAdicionarDetalle = await _unitOfWork.AppGeneralQuotesRepository.PermiteAdicionarDetalle(appGeneralQuotesGetDto.Id);

                appGeneralQuotesGetDto.PermiteAdicionarDetalle = permiteAdicionarDetalle;

                appGeneralQuotesGetDto.AppGeneralQuotesActionSheetDto = await GetAppGeneralQuotesActionSheetDto(appGeneralQuotesGetDto.Id);

                ApiResponse <List <AppDetailQuotesGetDto> > listDetail = await _appDetailQuotesService.GetListAppDetailQuoteByAppGeneralQuotesId(appGeneralQuotesGetDto.Id);

                if (listDetail != null)
                {
                    appGeneralQuotesGetDto.AppDetailQuotesGetDto = listDetail.Data;
                }



                return(appGeneralQuotesGetDto);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> GetListAppDetailQuoteByAppGeneralQuotesId(AppDetailQuotesQueryFilter filter)
        {
            Metadata metadata = new Metadata
            {
                IsValid    = false,
                Message    = "",
                TotalCount = 0
            };


            try
            {
                Core.Responses.ApiResponse <List <AppDetailQuotesGetDto> > detailQuotes = await _appDetailQuotesService.GetListAppDetailQuoteByAppGeneralQuotesId(filter.AppGeneralQuotesId);

                return(Ok(detailQuotes));
            }
            catch (Exception e)
            {
                metadata.IsValid = false;
                metadata.Message = e.InnerException.Message;
                ApiResponse <AppGeneralQuotesGetDto> responseError = new ApiResponse <AppGeneralQuotesGetDto>(null)
                {
                    Meta = metadata
                };


                return(Ok(responseError));
            }
        }