public async Task <MtrTipoMoneda> Insert(MtrTipoMoneda mtrTipoMoneda) { await _unitOfWork.MtrTipoMonedaRepository.Add(mtrTipoMoneda); await _unitOfWork.SaveChangesAsync(); return(mtrTipoMoneda); }
public async Task <MtrTipoMoneda> Update(MtrTipoMoneda mtrTipoMoneda) { var monedas = await GetById(mtrTipoMoneda.Id); if (monedas == null) { throw new Exception("Banco No existe"); } _unitOfWork.MtrTipoMonedaRepository.Update(mtrTipoMoneda); await _unitOfWork.SaveChangesAsync(); return(await GetById(monedas.Id)); }
public async Task <ApiResponse <AppGeneralQuotesGetDto> > UpdateGeneralQuotes(AppGeneralQuotesUpdateDto appGeneralQuotesUpdateDto) { AppGeneralQuotesGetDto resultDto = new AppGeneralQuotesGetDto(); Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <AppGeneralQuotesGetDto> response = new ApiResponse <AppGeneralQuotesGetDto>(resultDto); try { AppGeneralQuotes appGeneralQuotes = await GetById(appGeneralQuotesUpdateDto.Id); if (appGeneralQuotes == null) { metadata.IsValid = false; metadata.Message = "Cotizacion No Existe!!! " + appGeneralQuotesUpdateDto.Cotizacion; response.Meta = metadata; response.Data = resultDto; return(response); } MtrCliente cliente = await _mtrClienteService.GetByIdAsync(appGeneralQuotesUpdateDto.IdCliente); if (cliente == null) { metadata.IsValid = false; metadata.Message = "Cliente No Existe!!! " + appGeneralQuotesUpdateDto.IdCliente; response.Meta = metadata; response.Data = resultDto; return(response); } MtrDirecciones direccionEntregarValidate = await _unitOfWork.MtrDireccionesRepository.GetById(appGeneralQuotesUpdateDto.IdDireccionEntregar); if (direccionEntregarValidate == null) { metadata.IsValid = false; metadata.Message = "Direccion Entregar No Existe!!! " + appGeneralQuotesUpdateDto.IdDireccionEntregar; response.Meta = metadata; response.Data = resultDto; return(response); } MtrContactos mtrContactosValidate = await _unitOfWork.MtrContactosRepository.GetById(appGeneralQuotesUpdateDto.IdContacto); if (mtrContactosValidate == null) { metadata.IsValid = false; metadata.Message = "Contacto No Existe!!! "; response.Meta = metadata; response.Data = resultDto; return(response); } MtrCondicionPago condicionPagoValidate = await _unitOfWork.MtrCondicionPagoRepository.GetById(appGeneralQuotesUpdateDto.IdCondPago); if (condicionPagoValidate == null) { metadata.IsValid = false; metadata.Message = "Condicion de Pago No Existe!!! "; response.Meta = metadata; response.Data = resultDto; return(response); } MtrTipoMoneda mtrTipoMonedaFind = await _unitOfWork.MtrTipoMonedaRepository.GetById(appGeneralQuotesUpdateDto.IdMtrTipoMoneda); if (mtrTipoMonedaFind == null) { metadata.IsValid = false; metadata.Message = "Moneda No Existe!!! "; response.Meta = metadata; response.Data = resultDto; return(response); } if (appGeneralQuotesUpdateDto.OrdenCompra.Length > 16) { metadata.IsValid = false; metadata.Message = "Longitud Maxima de Orden de Compra es 16 !!! "; response.Meta = metadata; response.Data = resultDto; return(response); } if (appGeneralQuotesUpdateDto.IdCliente != "000000") { appGeneralQuotesUpdateDto.Rif = cliente.NoRegTribut; appGeneralQuotesUpdateDto.RazonSocial = cliente.Nombre; appGeneralQuotesUpdateDto.Direccion = cliente.Direccion + " " + cliente.Direccion1; } appGeneralQuotes.Rif = appGeneralQuotesUpdateDto.Rif; appGeneralQuotes.RazonSocial = appGeneralQuotesUpdateDto.RazonSocial; appGeneralQuotes.Direccion = appGeneralQuotesUpdateDto.Direccion; appGeneralQuotes.IdCliente = appGeneralQuotesUpdateDto.IdCliente; if (appGeneralQuotesUpdateDto.IdCliente == "000000") { appGeneralQuotes.IdMunicipio = appGeneralQuotesUpdateDto.IdMunicipio; var municipio = await _unitOfWork.Winy243Repository.GetById(appGeneralQuotesUpdateDto.IdMunicipio); if (municipio != null) { appGeneralQuotes.DescripcionMunicipio = municipio.DescMunicipio; } } else { var municipio = await _unitOfWork.Winy243Repository.GetByEstadoMunicipio(direccionEntregarValidate.Estado, direccionEntregarValidate.Municipio); if (municipio != null) { appGeneralQuotes.IdMunicipio = municipio.Recnum; appGeneralQuotes.DescripcionMunicipio = municipio.DescMunicipio; } } if (appGeneralQuotesUpdateDto.IdCliente != "000000") { appGeneralQuotes.IdVendedor = cliente.Vendedor1.Trim(); } else { appGeneralQuotes.IdVendedor = appGeneralQuotesUpdateDto.UsuarioActualiza; } appGeneralQuotes.Observaciones = appGeneralQuotesUpdateDto.Observaciones; appGeneralQuotes.IdCondPago = appGeneralQuotesUpdateDto.IdCondPago; appGeneralQuotes.IdContacto = appGeneralQuotesUpdateDto.IdContacto; appGeneralQuotes.IdDireccionFacturar = (decimal)cliente.IdDireccion; appGeneralQuotes.IdDireccionEntregar = appGeneralQuotesUpdateDto.IdDireccionEntregar; appGeneralQuotes.OrdenCompra = appGeneralQuotesUpdateDto.OrdenCompra; appGeneralQuotes.UsuarioActualiza = appGeneralQuotesUpdateDto.UsuarioActualiza; appGeneralQuotes.FechaActualiza = DateTime.Now; appGeneralQuotes.Proximo = 0; appGeneralQuotes.IdMtrTipoMoneda = appGeneralQuotesUpdateDto.IdMtrTipoMoneda; if (appGeneralQuotesUpdateDto.FechaPostergada != null) { appGeneralQuotes.FechaPostergada = appGeneralQuotesUpdateDto.FechaPostergada; } if (appGeneralQuotesUpdateDto.ObservacionPostergar != "" && appGeneralQuotesUpdateDto.ObservacionPostergar != null) { appGeneralQuotes.ObservacionPostergar = appGeneralQuotesUpdateDto.ObservacionPostergar; } else { appGeneralQuotesUpdateDto.ObservacionPostergar = ""; } appGeneralQuotes.FijarPrecioBs = appGeneralQuotesUpdateDto.FijarPrecioBs; AppStatusQuote appStatusQuote = await _unitOfWork.AppStatusQuoteRepository.GetById(appGeneralQuotes.IdEstatus); MtrVendedor vendedor = _unitOfWork.MtrVendedorRepository.GetById(appGeneralQuotes.IdVendedor); if (appGeneralQuotesUpdateDto.IdCliente != "000000") { appGeneralQuotes.SearchText = $"{appGeneralQuotes.Cotizacion}-{appGeneralQuotes.IdVendedor}-{vendedor.Nombre.Trim()}-{appGeneralQuotes.IdCliente}-{cliente.Nombre.Trim()}{appGeneralQuotes.IdVendedor}-{vendedor.Nombre.Trim()}-{appGeneralQuotes.IdCliente}-{appGeneralQuotes.RazonSocial.Trim()}-{appStatusQuote.Descripcion.Trim()}"; } else { appGeneralQuotes.SearchText = $"{appGeneralQuotes.Cotizacion}-{appGeneralQuotes.IdVendedor}-{vendedor.Nombre.Trim()}-{appGeneralQuotes.IdCliente}-{appGeneralQuotes.RazonSocial.Trim()}-{appStatusQuote.Descripcion.Trim()}"; appGeneralQuotes.IdDireccionEntregar = 1; appGeneralQuotes.IdDireccionFacturar = 1; } AppGeneralQuotes AppGeneralQuotesUpdated = await Update(appGeneralQuotes); //await _cotizacionService.IntegrarCotizacion(AppGeneralQuotesUpdated.Id); if (AppGeneralQuotesUpdated != null) { resultDto = _mapper.Map <AppGeneralQuotesGetDto>(AppGeneralQuotesUpdated); MtrVendedor mtrVendedor = _unitOfWork.MtrVendedorRepository.GetById(resultDto.IdVendedor); if (mtrVendedor != null) { MtrVendedorDto mtrVendedorDto = _mapper.Map <MtrVendedorDto>(mtrVendedor); resultDto.MtrVendedorDto = mtrVendedorDto; } MtrCliente mtrCliente = _unitOfWork.MtrClienteRepository.GetById(resultDto.IdCliente); if (mtrCliente != null) { MtrClienteDto mtrClienteDto = _mapper.Map <MtrClienteDto>(mtrCliente); resultDto.MtrClienteDto = mtrClienteDto; } MtrContactos mtrContactos = await _unitOfWork.MtrContactosRepository.GetById(resultDto.IdContacto); if (mtrContactos != null) { MtrContactosDto mtrContactosDto = _mapper.Map <MtrContactosDto>(mtrContactos); resultDto.MtrContactosDto = mtrContactosDto; } MtrDirecciones direccionEntregar = await _unitOfWork.MtrDireccionesRepository.GetById(resultDto.IdDireccionEntregar); if (direccionEntregar != null) { MtrDireccionesDto direccionEntregarDto = _mapper.Map <MtrDireccionesDto>(direccionEntregar); resultDto.MtrDireccionesEntregarDto = direccionEntregarDto; } MtrDirecciones direccionFacturar = await _unitOfWork.MtrDireccionesRepository.GetById(resultDto.IdDireccionFacturar); if (direccionFacturar != null) { MtrDireccionesDto direccionFacturarDto = _mapper.Map <MtrDireccionesDto>(direccionFacturar); resultDto.MtrDireccionesFacturarDto = direccionFacturarDto; } MtrCondicionPago condicionPago = await _unitOfWork.MtrCondicionPagoRepository.GetById(resultDto.IdCondPago); if (condicionPago != null) { CondicionPagoDto condicionPagoDto = _mapper.Map <CondicionPagoDto>(condicionPago); resultDto.CondicionPagoDto = condicionPagoDto; } MtrTipoMoneda mtrTipoMoneda = await _unitOfWork.MtrTipoMonedaRepository.GetById(resultDto.IdMtrTipoMoneda); if (mtrTipoMoneda != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(mtrTipoMoneda); resultDto.MtrTipoMonedaDto = mtrTipoMonedaDto; } metadata.IsValid = true; metadata.Message = $"Cotizacion: {resultDto.Cotizacion} Actualizada Satisfactoriamente!!"; } else { metadata.IsValid = false; metadata.Message = "Registro No actualizado"; } response.Meta = metadata; response.Data = resultDto; return(response); } catch (Exception ex) { metadata.IsValid = false; metadata.Message = ex.InnerException.Message; response.Meta = metadata; response.Data = resultDto; return(response); } }
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); } }
public async Task <PagedList <AppGeneralQuotesGetDto> > GetAllAppGeneralQuotes(AppGeneralQuotesQueryFilter filters) { filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber; filters.PageSize = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize; List <AppGeneralQuotes> quotes = await _unitOfWork.AppGeneralQuotesRepository.GetAll(filters); if (quotes.Count > 0) { List <AppGeneralQuotesGetDto> appGeneralQuotesGetDto = _mapper.Map <List <AppGeneralQuotesGetDto> >(quotes); foreach (AppGeneralQuotesGetDto item in appGeneralQuotesGetDto) { MtrVendedor mtrVendedor = _unitOfWork.MtrVendedorRepository.GetById(item.IdVendedor); if (mtrVendedor != null) { MtrVendedorDto mtrVendedorDto = _mapper.Map <MtrVendedorDto>(mtrVendedor); item.MtrVendedorDto = mtrVendedorDto; } MtrCliente mtrCliente = _unitOfWork.MtrClienteRepository.GetById(item.IdCliente); if (mtrCliente != null) { MtrClienteDto mtrClienteDto = _mapper.Map <MtrClienteDto>(mtrCliente); item.MtrClienteDto = mtrClienteDto; if (item.IdCliente == "000000") { item.MtrClienteDto.Descripcion = item.IdCliente.Trim() + "-" + item.RazonSocial.Trim() + " RIF: " + item.Rif.ToString(); } } MtrContactos mtrContactos = await _unitOfWork.MtrContactosRepository.GetById(item.IdContacto); if (mtrContactos != null) { MtrContactosDto mtrContactosDto = _mapper.Map <MtrContactosDto>(mtrContactos); item.MtrContactosDto = mtrContactosDto; } MtrDirecciones direccionEntregar = await _unitOfWork.MtrDireccionesRepository.GetById(item.IdDireccionEntregar); if (direccionEntregar != null) { MtrDireccionesDto direccionEntregarDto = _mapper.Map <MtrDireccionesDto>(direccionEntregar); item.MtrDireccionesEntregarDto = direccionEntregarDto; } MtrDirecciones direccionFacturar = await _unitOfWork.MtrDireccionesRepository.GetById(item.IdDireccionFacturar); if (direccionFacturar != null) { MtrDireccionesDto direccionFacturarDto = _mapper.Map <MtrDireccionesDto>(direccionFacturar); item.MtrDireccionesFacturarDto = direccionFacturarDto; } MtrCondicionPago condicionPago = await _unitOfWork.MtrCondicionPagoRepository.GetById(item.IdCondPago); if (condicionPago != null) { CondicionPagoDto condicionPagoDto = _mapper.Map <CondicionPagoDto>(condicionPago); item.CondicionPagoDto = condicionPagoDto; } MtrTipoMoneda mtrTipoMoneda = await _unitOfWork.MtrTipoMonedaRepository.GetById(item.IdMtrTipoMoneda); if (mtrTipoMoneda != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(mtrTipoMoneda); item.MtrTipoMonedaDto = mtrTipoMonedaDto; } var actualizar = await _unitOfWork.AppGeneralQuotesRepository.VerificarStatus(item.Id); if (actualizar) { await _unitOfWork.SaveChangesAsync(); } AppStatusQuote appStatusQuote = await _unitOfWork.AppStatusQuoteRepository.GetById(item.IdEstatus); if (appStatusQuote != null) { AppStatusQuoteGetDto appStatusQuoteDto = _mapper.Map <AppStatusQuoteGetDto>(appStatusQuote); item.AppStatusQuoteGetDto = appStatusQuoteDto; } if (item.IdCliente == "000000") { var municipio = await _unitOfWork.Winy243Repository.GetById(item.IdMunicipio); if (municipio != null) { item.PorcFlete = municipio.PorcFlete; MunicipioGetDto municipioGetDto = _mapper.Map <MunicipioGetDto>(municipio); item.MunicipioGetDto = municipioGetDto; } } else { item.PorcFlete = await GetFleteByIdDireccionEntrega(item.IdDireccionEntregar); var municipio = await _unitOfWork.Winy243Repository.GetByEstadoMunicipio(direccionEntregar.Estado, direccionEntregar.Municipio); if (municipio != null) { item.IdMunicipio = municipio.Recnum; item.descripcionMunicipio = municipio.DescMunicipio; MunicipioGetDto municipioGetDto = _mapper.Map <MunicipioGetDto>(municipio); item.MunicipioGetDto = municipioGetDto; } } var permiteAdicionarDetalle = await _unitOfWork.AppGeneralQuotesRepository.PermiteAdicionarDetalle(item.Id); item.PermiteAdicionarDetalle = permiteAdicionarDetalle; item.AppGeneralQuotesActionSheetDto = await GetAppGeneralQuotesActionSheetDto(item.Id); ApiResponse <List <AppDetailQuotesGetDto> > listDetail = await _appDetailQuotesService.GetListAppDetailQuoteByAppGeneralQuotesId(item.Id); if (listDetail != null) { item.AppDetailQuotesGetDto = listDetail.Data; } item.FechaString = item.Fecha.ToString("dd/MM/yyyy"); } PagedList <AppGeneralQuotesGetDto> pagedResult = PagedList <AppGeneralQuotesGetDto> .Create(appGeneralQuotesGetDto, filters.PageNumber, filters.PageSize); return(pagedResult); } else { return(null); } }
public async Task <ReciboDto> GeneraReciboDto(long recibo) { ReciboDto result = new ReciboDto(); CobGeneralCobranza cobGeneralCobranza = new CobGeneralCobranza(); List <CobGrabacionCobranzas> listaCobGrabacionCobranzas = new List <CobGrabacionCobranzas>(); try { //Crea Objeto General cobranzas cobGeneralCobranza = await GetGeneralCobranzaPorDocumento(recibo); CobGeneralCobranzaDto generalCobranzasDtos = _mapper.Map <CobGeneralCobranzaDto>(cobGeneralCobranza); MtrCliente cliente = await _mtrClienteService.GetByIdAsync(generalCobranzasDtos.IdCliente); MtrVendedor vendedor = await _mtrVendedorService.GetByIdAsync(cliente.Vendedor1); generalCobranzasDtos.NombreCliente = cliente.NoRegTribut + " " + cliente.Nombre.Trim(); generalCobranzasDtos.IdCliente = generalCobranzasDtos.IdCliente.Trim(); generalCobranzasDtos.FechaTransaccionString = generalCobranzasDtos.FechaTransaccion.ToShortDateString(); generalCobranzasDtos.NombreVendedor = vendedor.Nombre; generalCobranzasDtos.vendedor = vendedor.Codigo; generalCobranzasDtos.CorreoVendedor = vendedor.EMail; generalCobranzasDtos.TelefonoVendedor = vendedor.TlfCelular; decimal decimalValue = generalCobranzasDtos.MontoTransaccion; generalCobranzasDtos.MontoTransaccionString = string.Format("{0:N}", decimalValue); // 1,234,567.00 //creamos el objeto Moneda oMoneda = new Moneda(); //primer parametro es la cantidad en string //segundo parametro es si queremos que sea mayuscula //tercer parametro la moneda MtrTipoMoneda tipoMoneda = await _mtrTipoMonedaService.GetById((long)cobGeneralCobranza.IdMtrTipoMoneda); string MonedaString = tipoMoneda.Descripcion; string resultado = oMoneda.Convertir(generalCobranzasDtos.MontoTransaccion.ToString(), true, MonedaString); generalCobranzasDtos.MontoLetras = resultado; decimal?detalleValue = generalCobranzasDtos.TotalDetalleCobrado; generalCobranzasDtos.TotalDetalleCobradoString = string.Format("{0:N}", detalleValue); generalCobranzasDtos.Status = EstatusRecibo(cobGeneralCobranza); MtrBancos banco = await _mtrBancosService.GetByCodigo(generalCobranzasDtos.IdBanco); generalCobranzasDtos.NombreBanco = banco.Nombre; CobTipoTransaccion tipoTransaccion = await _cobTipoTransaccionService.GetById(generalCobranzasDtos.IdTipoTransaccion); generalCobranzasDtos.NombreTipoTransaccion = tipoTransaccion.NombreTipoTransaccion; generalCobranzasDtos.FlagImpuesto = tipoTransaccion.FlagImpuesto; MtrTipoMoneda mtrTipoMoneda = await _mtrTipoMonedaService.GetById((long)generalCobranzasDtos.IdMtrTipoMoneda); generalCobranzasDtos.NombreTipoMoneda = mtrTipoMoneda.Descripcion; listaCobGrabacionCobranzas = _unitOfWork.CobGrabacionCobranzasRepository.GetByDocumento(recibo); listaCobGrabacionCobranzas = listaCobGrabacionCobranzas.Where(x => x.DocumentoSap == "").ToList(); List <CobGrabacionCobranzaDto> listaCobGrabacionCobranzasDto = _mapper.Map <List <CobGrabacionCobranzaDto> >(listaCobGrabacionCobranzas); foreach (CobGrabacionCobranzaDto item in listaCobGrabacionCobranzasDto) { item.CuentaBancaria = banco.CodContable; item.Moneda = mtrTipoMoneda.Descripcion; if (item.Transaccion == "RU") { item.DocAfectaMostrar = item.Cotizacion; } else { item.DocAfectaMostrar = item.DocAfectaSap; } decimalValue = (decimal)item.Monto; item.MontoMostrar = string.Format("{0:N}", decimalValue); // 1,234,567.00 CobEstadoDeCuenta cobEstadoDeCuenta = await _cobEstadoCuentaService.GetEstadoCuentaById(item.DocAfecta); if (cobEstadoDeCuenta != null) { decimalValue = (decimal)cobEstadoDeCuenta.BaseImponible; item.BaseImponible = (decimal)cobEstadoDeCuenta.BaseImponible; item.BaseImponibleMostrar = string.Format("{0:N}", decimalValue); // 1,234,567.00 decimalValue = (decimal)cobEstadoDeCuenta.Iva; item.Iva = (decimal)cobEstadoDeCuenta.Iva; item.IvaMostrar = string.Format("{0:N}", decimalValue); // 1,234,567.00 decimalValue = (decimal)cobEstadoDeCuenta.MontoOriginal; item.MontoOriginalMostrar = string.Format("{0:N}", decimalValue); // 1,234,567.00 item.FechaDocumento = cobEstadoDeCuenta.FechaDocumento; DateTime fechaDocumento = (DateTime)cobEstadoDeCuenta.FechaDocumento; item.FechaDocumentoString = fechaDocumento.ToShortDateString(); } //List<CobPagosRetencionesDto> listCobPagosRetencionesDto = new List<CobPagosRetencionesDto>(); List <CobPagosRetenciones> listCobPagosRetenciones = _unitOfWork.CobPagosRetencionesRepository.GetByIdCobranzas(item.Id); List <CobPagosRetencionesDto> listCobPagosRetencionesDto = _mapper.Map <List <CobPagosRetencionesDto> >(listCobPagosRetenciones); if (listCobPagosRetencionesDto != null && listCobPagosRetencionesDto.Count > 0) { foreach (CobPagosRetencionesDto itemRet in listCobPagosRetencionesDto) { decimalValue = itemRet.Monto; itemRet.MontoString = string.Format("{0:N}", decimalValue); // 1,234,567.00 CobTransacciones transaccion = await _cobTransaccionesService.GetById(itemRet.IdTransaccion); if (transaccion != null) { itemRet.NombreTransaccion = transaccion.NombreTransaccion; itemRet.TxOrigen = transaccion.TipoSap; } itemRet.FechaComprobanteString = itemRet.FechaComprobante.ToShortDateString(); } } item.CobPagosRetencionesDto = listCobPagosRetencionesDto; } result.CobGeneralCobranzaDto = generalCobranzasDtos; result.CobGrabacionCobranzaDto = listaCobGrabacionCobranzasDto; return(result); } catch (Exception e) { string message = e.Message; throw; } }
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 <AppIngredientsGetDto> > UpdateAppIngredient(AppIngredientsUpdateDto dto) { AppIngredientsGetDto resultDto = new AppIngredientsGetDto(); Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <AppIngredientsGetDto> response = new ApiResponse <AppIngredientsGetDto>(resultDto); try { var ingredient = await GetById(dto.Id); if (ingredient == null) { metadata.IsValid = false; metadata.Message = "Ingrediente No existe"; response.Data = resultDto; response.Meta = metadata; return(response); } if (dto.Code == null || dto.Code == "") { metadata.IsValid = false; metadata.Message = "Codigo Invalido"; response.Data = resultDto; response.Meta = metadata; return(response); } if (dto.Description == null || dto.Description == "") { metadata.IsValid = false; metadata.Message = "Descripcion Invalida"; response.Data = resultDto; response.Meta = metadata; return(response); } if (dto.Cost <= 0) { metadata.IsValid = false; metadata.Message = "Costo Invalido"; response.Data = resultDto; response.Meta = metadata; return(response); } AppUnits AppUnitsFind = await _appUnitsService.GetById(dto.AppUnitId); if (AppUnitsFind == null) { metadata.IsValid = false; metadata.Message = "Unidad de Medida no existe!!"; response.Data = resultDto; response.Meta = metadata; return(response); } MtrTipoMoneda MtrTipoMonedaPrymaryFind = await _mtrTipoMonedaService.GetById((long)dto.PrymaryMtrMonedaId); if (MtrTipoMonedaPrymaryFind == null) { metadata.IsValid = false; metadata.Message = "Moneda Primaria no existe!!"; response.Data = resultDto; response.Meta = metadata; return(response); } MtrTipoMoneda MtrTipoMonedaSecundaryFind = await _mtrTipoMonedaService.GetById((long)dto.SecundaryMtrMonedaId); if (MtrTipoMonedaSecundaryFind == null) { metadata.IsValid = false; metadata.Message = "Moneda Secundaria no existe!!"; response.Data = resultDto; response.Meta = metadata; return(response); } ingredient.Code = dto.Code; ingredient.Description = dto.Description; ingredient.Cost = dto.Cost; ingredient.AppUnitId = dto.AppUnitId; ingredient.PrymaryMtrMonedaId = dto.PrymaryMtrMonedaId; ingredient.SecundaryMtrMonedaId = dto.SecundaryMtrMonedaId; ingredient.UserUpdate = dto.UsuarioConectado; ingredient.UpdatedAt = DateTime.Now; var updated = await Update(ingredient); resultDto = _mapper.Map <AppIngredientsGetDto>(updated); await RecalculateRecipesByIngredient(ingredient.Id); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); resultDto.AppUnitsGetDto = appUnitsGetDto; } if (MtrTipoMonedaPrymaryFind != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(MtrTipoMonedaPrymaryFind); resultDto.PrymaryMtrMonedaDto = mtrTipoMonedaDto; } if (MtrTipoMonedaSecundaryFind != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(MtrTipoMonedaSecundaryFind); resultDto.SecundaryMtrMonedaDto = mtrTipoMonedaDto; } response.Data = resultDto; 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 <IActionResult> Update(CobGrabacionCobranzaDto cobGrabacionCobranzaDto) { CobGrabacionCobranzaDto resultDto = new CobGrabacionCobranzaDto(); Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <CobGrabacionCobranzaDto> response = new ApiResponse <CobGrabacionCobranzaDto>(resultDto); CobGrabacionCobranzas cobGrabacionCobranza = _mapper.Map <CobGrabacionCobranzas>(cobGrabacionCobranzaDto); CobGeneralCobranza generalCobranza = await _generalCobranzaService.GetGeneralCobranzaPorDocumento((long)cobGrabacionCobranza.Documento); MtrTipoMoneda tipomoneda = await _mtrTipoMonedaService.GetById((long)generalCobranza.IdMtrTipoMoneda); CobEstadoDeCuenta estadoCuenta = await _cobEstadoCuentaService.GetEstadoCuentaById(cobGrabacionCobranzaDto.DocAfecta); if (estadoCuenta != null) { CobGrabacionCobranzas grabacionActual = await _cobGrabacionCobranzasService.GetById(cobGrabacionCobranzaDto.Id); if (cobGrabacionCobranzaDto.Transaccion != "RU") { if (generalCobranza.IdTipoTransaccion != "RET") { bool existeMonedaDocumentoMonedaPago = await _cobMatrixMonedaValidaPagoService.ExisteMonedaDocumentoMonedaPago(estadoCuenta.Moneda, tipomoneda.Descripcion); if (!existeMonedaDocumentoMonedaPago) { metadata.IsValid = false; metadata.Message = "Esta intentando grabar cobro en moneda no valida a el Recibo"; response.Meta = metadata; return(Ok(response)); } } decimal totalAfectadoDocumento = _cobGrabacionCobranzasService.TotalAfectadoDocumento((long)cobGrabacionCobranzaDto.Documento, cobGrabacionCobranzaDto.DocAfecta); decimal totalAfectadoDocumentoResta = totalAfectadoDocumento - (decimal)grabacionActual.Monto; if (totalAfectadoDocumentoResta + (decimal)cobGrabacionCobranzaDto.Monto > (decimal)estadoCuenta.Rpaap) { metadata.IsValid = false; metadata.Message = "Esta intentando grabar monto superior al saldo del documento:" + "Total registrado en recibo: " + totalAfectadoDocumento.ToString() + "Saldo documento: " + estadoCuenta.Rpaap.ToString(); response.Meta = metadata; return(Ok(response)); } } } CobGrabacionCobranzas grabacionCobranzaActual = await _cobGrabacionCobranzasService.GetById(cobGrabacionCobranzaDto.Id); if (grabacionCobranzaActual.DocumentoSap.Length > 1) { metadata.IsValid = false; metadata.Message = "Esta intentando modificar un cobro ya contabilizado"; response.Meta = metadata; return(Ok(response)); } CobGrabacionCobranzas cobranza = await _cobGrabacionCobranzasService.Update(cobGrabacionCobranza); if (cobranza != null) { resultDto = _mapper.Map <CobGrabacionCobranzaDto>(cobranza); metadata.IsValid = true; metadata.Message = "Actualizado Satisfactoriamente"; } else { metadata.IsValid = false; metadata.Message = "Registro No actualizado"; } //ApiResponse<CobGrabacionCobranzaDto> response = new ApiResponse<CobGrabacionCobranzaDto>(resultDto) //{ // Meta = metadata, //}; response.Meta = metadata; response.Data = resultDto; return(Ok(response)); }
public async Task <ApiResponse <AppProductsGetDto> > GetProduct(int id) { AppProductsGetDto resultDto = new AppProductsGetDto(); Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <AppProductsGetDto> response = new ApiResponse <AppProductsGetDto>(resultDto); try { AppProducts appProductsFind = await GetById(id); if (appProductsFind == null) { metadata.IsValid = false; metadata.Message = "Codigo de producto no existe, verifique por favor"; response.Meta = metadata; response.Data = resultDto; return(response); } resultDto = _mapper.Map <AppProductsGetDto>(appProductsFind); AppUnits AppUnitsFind = await _appUnitsService.GetById((int)appProductsFind.AppUnitsId); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); resultDto.AppUnitsGetDto = appUnitsGetDto; } AppUnitsFind = await _appUnitsService.GetById((int)appProductsFind.ProductionUnitId); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); resultDto.ProductionUnitGetDto = appUnitsGetDto; } MtrTipoMoneda MtrTipoMonedaFind = await _mtrTipoMonedaService.GetById((long)appProductsFind.PrymaryMtrMonedaId); if (MtrTipoMonedaFind != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(MtrTipoMonedaFind); resultDto.PrymaryMtrMonedaGetDto = mtrTipoMonedaDto; } MtrTipoMonedaFind = await _mtrTipoMonedaService.GetById((long)appProductsFind.SecundaryMtrMonedaId); if (MtrTipoMonedaFind != null) { MtrTipoMonedaDto mtrTipoMonedaDto = _mapper.Map <MtrTipoMonedaDto>(MtrTipoMonedaFind); resultDto.SecundaryMtrMonedaGetDto = mtrTipoMonedaDto; } AppSubCategory AppSubCategoryFind = await _appSubCategoryService.GetById((int)appProductsFind.AppSubCategoryId); if (AppSubCategoryFind != null) { AppSubCategoryGetDto appSubCategoryGetDto = _mapper.Map <AppSubCategoryGetDto>(AppSubCategoryFind); resultDto.AppSubCategoryGetDto = appSubCategoryGetDto; } if (resultDto.UrlImage == "" || resultDto.UrlImage == null) { resultDto.Link = _paginationOptions.UrlGetFiles + "NoImage.png"; } else { resultDto.Link = _paginationOptions.UrlGetFiles + resultDto.UrlImage; } response.Meta = metadata; response.Data = resultDto; return(response); } catch (Exception ex) { metadata.IsValid = false; metadata.Message = ex.InnerException.Message; response.Meta = metadata; response.Data = resultDto; return(response); } }
public async Task <IActionResult> Insert(CobGrabacionCobranzaDto cobGrabacionCobranzaDto) { CobGrabacionCobranzaDto resultDto = new CobGrabacionCobranzaDto(); Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <CobGrabacionCobranzaDto> response = new ApiResponse <CobGrabacionCobranzaDto>(resultDto); try { CobGeneralCobranza generalCobranza = await _generalCobranzaService.GetGeneralCobranzaPorDocumento((long)cobGrabacionCobranzaDto.Documento); if (cobGrabacionCobranzaDto.Transaccion == "RU" && generalCobranza.FlagPagoMas != true) { OfdCotizacion cotizacion = new OfdCotizacion(); cotizacion = await _ofdCotizacionService.GetCotizacion(cobGrabacionCobranzaDto.Cotizacion); if (cotizacion != null) { if (cotizacion.IdCliente == generalCobranza.IdCliente) { metadata.IsValid = true; metadata.Message = ""; } else { metadata.IsValid = false; metadata.Message = "Cotizacion no pertenece a este cliente!!! " + generalCobranza.IdCliente; response.Meta = metadata; response.Data = resultDto; return(Ok(response)); } } else { metadata.IsValid = false; metadata.Message = "Cotizacion no existe!!!"; response.Meta = metadata; response.Data = resultDto; return(Ok(response)); } } CobGrabacionCobranzas cobGrabacionCobranza = _mapper.Map <CobGrabacionCobranzas>(cobGrabacionCobranzaDto); MtrTipoMoneda tipomoneda = await _mtrTipoMonedaService.GetById((long)generalCobranza.IdMtrTipoMoneda); bool dividirPagoImpuesto = false; CobEstadoDeCuenta estadoCuenta = await _cobEstadoCuentaService.GetEstadoCuentaById(cobGrabacionCobranzaDto.DocAfecta); if (estadoCuenta != null) { if (cobGrabacionCobranzaDto.Transaccion != "RU") { if (generalCobranza.IdTipoTransaccion != "RET") { bool existeMonedaDocumentoMonedaPago = await _cobMatrixMonedaValidaPagoService.ExisteMonedaDocumentoMonedaPago(estadoCuenta.Moneda, tipomoneda.Descripcion); if (!existeMonedaDocumentoMonedaPago) { metadata.IsValid = false; metadata.Message = "Esta intentando grabar cobro en moneda no valida a el Recibo"; response.Meta = metadata; return(Ok(response)); } decimal totalAfectadoDocumento = _cobGrabacionCobranzasService.TotalAfectadoDocumento((long)cobGrabacionCobranzaDto.Documento, cobGrabacionCobranzaDto.DocAfecta); if (totalAfectadoDocumento + (decimal)cobGrabacionCobranzaDto.Monto > (decimal)estadoCuenta.Rpaap) { metadata.IsValid = false; metadata.Message = "Esta intentando grabar monto superior al saldo del documento:" + "Total registrado en recibo: " + totalAfectadoDocumento.ToString() + "Saldo documento: " + estadoCuenta.Rpaap.ToString(); return(Ok(response)); } } } if (cobGrabacionCobranzaDto.Monto > estadoCuenta.BaseImponible && cobGrabacionCobranzaDto.Transaccion != "RE" && tipomoneda.Descripcion == estadoCuenta.Moneda) { dividirPagoImpuesto = true; } } if (!dividirPagoImpuesto) { cobGrabacionCobranza.PagoCorrespondeIva = false; CobGrabacionCobranzas cobranza = await _cobGrabacionCobranzasService.Insert(cobGrabacionCobranza); if (cobranza != null) { resultDto = _mapper.Map <CobGrabacionCobranzaDto>(cobranza); metadata.IsValid = true; metadata.Message = "Creado Satisfactoriamente"; } else { metadata.IsValid = false; metadata.Message = "Registro No actualizado"; } } else { CobGrabacionCobranzas cobGrabacionCobranzaImpuesto = _mapper.Map <CobGrabacionCobranzas>(cobGrabacionCobranzaDto); decimal?montoGrabado = cobGrabacionCobranza.Monto; cobGrabacionCobranza.Monto = estadoCuenta.BaseImponible; cobGrabacionCobranza.PagoCorrespondeIva = false; CobGrabacionCobranzas cobranza = await _cobGrabacionCobranzasService.Insert(cobGrabacionCobranza); cobGrabacionCobranzaImpuesto.Monto = montoGrabado - estadoCuenta.BaseImponible; cobGrabacionCobranzaImpuesto.PagoCorrespondeIva = true; CobGrabacionCobranzas cobranzaImpuesto = await _cobGrabacionCobranzasService.Insert(cobGrabacionCobranzaImpuesto); if (cobranza != null) { resultDto = _mapper.Map <CobGrabacionCobranzaDto>(cobranza); metadata.IsValid = true; metadata.Message = "Creado Satisfactoriamente"; } else { metadata.IsValid = false; metadata.Message = "Registro No actualizado"; } } //ApiResponse<CobGrabacionCobranzaDto> response = new ApiResponse<CobGrabacionCobranzaDto>(resultDto) //{ // Meta = metadata, //}; response.Meta = metadata; response.Data = resultDto; return(Ok(response)); } catch (Exception ex) { metadata.IsValid = false; metadata.Message = ex.InnerException.Message; response.Meta = metadata; response.Data = resultDto; //ApiResponse<CobGrabacionCobranzaDto> response = new ApiResponse<CobGrabacionCobranzaDto>(resultDto) //{ // Meta = metadata, //}; return(Ok(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); } }
public async Task <ApiResponse <AppProductsGetDto> > UpdateProducts(AppProductsUpdateDto appProductsUpdateDto) { AppProductsGetDto resultDto = new AppProductsGetDto(); Metadata metadata = new Metadata { IsValid = true, Message = "" }; ApiResponse <AppProductsGetDto> response = new ApiResponse <AppProductsGetDto>(resultDto); try { AppProducts appProductsFind = await GetById(appProductsUpdateDto.Id); if (appProductsFind == null) { metadata.IsValid = false; metadata.Message = "Codigo de producto no existe, verifique por favor"; response.Meta = metadata; response.Data = resultDto; return(response); } if (appProductsUpdateDto.ExternalCode == "") { metadata.IsValid = false; metadata.Message = "Codigo Externo no es valido"; response.Meta = metadata; response.Data = resultDto; return(response); } AppUnits appUnitsFind = await _appUnitsService.GetById((int)appProductsUpdateDto.AppUnitsId); if (appUnitsFind == null) { metadata.IsValid = false; metadata.Message = "Unidad venta del Producto No existe"; response.Meta = metadata; response.Data = resultDto; return(response); } appUnitsFind = await _appUnitsService.GetById((int)appProductsUpdateDto.ProductionUnitId); if (appUnitsFind == null) { metadata.IsValid = false; metadata.Message = "Unidad Produccion del Producto No existe"; response.Meta = metadata; response.Data = resultDto; return(response); } MtrTipoMoneda mtrTipoMonedaFind = await _unitOfWork.MtrTipoMonedaRepository.GetById((long)appProductsUpdateDto.PrymaryMtrMonedaId); if (mtrTipoMonedaFind == null) { metadata.IsValid = false; metadata.Message = "Moneda Primaria No Existe!!! "; response.Meta = metadata; response.Data = resultDto; return(response); } mtrTipoMonedaFind = await _unitOfWork.MtrTipoMonedaRepository.GetById((long)appProductsUpdateDto.SecundaryMtrMonedaId); if (mtrTipoMonedaFind == null) { metadata.IsValid = false; metadata.Message = "Moneda Secundaria No Existe!!! "; response.Meta = metadata; response.Data = resultDto; return(response); } AppSubCategory appSubCategory = await _unitOfWork.AppSubCategoryRepository.GetById((int)appProductsUpdateDto.AppSubCategoryId); if (appSubCategory == null) { metadata.IsValid = false; metadata.Message = "Subcategoria No Existe!!! "; response.Meta = metadata; response.Data = resultDto; return(response); } appProductsFind.ProductionUnitId = appProductsUpdateDto.ProductionUnitId; appProductsFind.AppUnitsId = appProductsUpdateDto.AppUnitsId; appProductsFind.AppSubCategoryId = appProductsUpdateDto.AppSubCategoryId; appProductsFind.PrymaryMtrMonedaId = appProductsUpdateDto.PrymaryMtrMonedaId; appProductsFind.SecundaryMtrMonedaId = appProductsUpdateDto.SecundaryMtrMonedaId; appProductsFind.UnitPrice = appProductsUpdateDto.UnitPrice; appProductsFind.Description1 = appProductsUpdateDto.Description1; appProductsFind.Description2 = appProductsUpdateDto.Description2; appProductsFind.ExternalCode = appProductsUpdateDto.ExternalCode; appProductsFind.UserUpdate = appProductsUpdateDto.UsuarioConectado; appProductsFind.UpdatedAt = DateTime.Now; AppProducts appProductsUpdated = await Update(appProductsFind); if (appProductsUpdated != null) { resultDto = _mapper.Map <AppProductsGetDto>(appProductsUpdated); AppUnits AppUnitsFind = await _appUnitsService.GetById((int)appProductsUpdated.AppUnitsId); if (AppUnitsFind != null) { AppUnitsGetDto appUnitsGetDto = _mapper.Map <AppUnitsGetDto>(AppUnitsFind); resultDto.AppUnitsGetDto = appUnitsGetDto; } if (resultDto.UrlImage == "" || resultDto.UrlImage == null) { resultDto.Link = _paginationOptions.UrlGetFiles + "NoImage.png"; } else { resultDto.Link = _paginationOptions.UrlGetFiles + resultDto.UrlImage; } metadata.IsValid = true; metadata.Message = $"Producto: {resultDto.Code} Actualizado Satisfactoriamente!!"; } else { metadata.IsValid = false; metadata.Message = "Registro No actualizado"; } response.Meta = metadata; response.Data = resultDto; return(response); } catch (Exception ex) { metadata.IsValid = false; metadata.Message = ex.InnerException.Message; response.Meta = metadata; response.Data = resultDto; return(response); } }
public async Task Delete(long id) { MtrTipoMoneda entity = await GetById(id); _context.MtrTipoMoneda.Remove(entity); }
public void Update(MtrTipoMoneda entity) { _context.MtrTipoMoneda.Update(entity); }
public async Task Add(MtrTipoMoneda entity) { await _context.MtrTipoMoneda.AddAsync(entity); }