public async Task <IActionResult> ActualizarPlanPago(PlanPagoDto planPagoDto) { usuarioId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); if (planPagoDto != null) { //Obtener todos los campos del plan de pago para una correcta actualización var planPagoBD = await _repo.ObtenerPlanPagoBase(planPagoDto.PlanPagoId); _mapper.Map(planPagoDto, planPagoBD); if (planPagoDto.esRadicarFactura) { planPagoBD.EstadoPlanPagoId = (int)EstadoPlanPago.PorObligar; planPagoBD.FechaFactura = _generalInterface.ObtenerFechaHoraActual(); planPagoBD.FechaRegistro = _generalInterface.ObtenerFechaHoraActual(); planPagoBD.UsuarioIdRegistro = usuarioId; } else { planPagoBD.EstadoPlanPagoId = (int)EstadoPlanPago.PorObligar; planPagoBD.FechaFactura = _generalInterface.ObtenerFechaHoraActual(); planPagoBD.FechaModificacion = _generalInterface.ObtenerFechaHoraActual(); planPagoBD.UsuarioIdModificacion = usuarioId; } //Para apagar manualmente la columna que no deseo modificar // _dataContext.Entry(planPagoBD).Property("RubroPresupuestalId").IsModified = false; //await _unitOfWork.CompleteAsync(); //Para solicitar la actualización de una entidad //_dataContext.Update(planPagoBD); await _unitOfWork.CompleteAsync(); return(NoContent()); } throw new Exception($"No se pudo actualizar la factura"); }
public List <PlanPagoDto> obtenerListaDePlanPago(DataTable dtPlanPago) { PlanPagoDto documento = null; List <PlanPagoDto> listaDocumento = new List <PlanPagoDto>(); int numValue = 0; decimal value = 0; DateTime fecha; foreach (var row in dtPlanPago.Rows) { documento = new PlanPagoDto(); //Cdp if (!(row as DataRow).ItemArray[1].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[1].ToString(), out numValue)) { if (numValue > 0) { documento.Cdp = numValue; } } } //Crp if (!(row as DataRow).ItemArray[2].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[2].ToString(), out numValue)) { if (numValue > 0) { documento.Crp = numValue; } } } //AnioPago if (!(row as DataRow).ItemArray[3].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[3].ToString(), out numValue)) { documento.AnioPago = numValue; } } //MesPago if (!(row as DataRow).ItemArray[4].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[4].ToString(), out numValue)) { documento.MesPago = numValue; } } //ValorInicial if (!(row as DataRow).ItemArray[5].ToString().Equals(string.Empty)) { if (decimal.TryParse((row as DataRow).ItemArray[5].ToString(), out value)) { if (value > 0) { documento.ValorInicial = value; } } } //ValorAdicion if (!(row as DataRow).ItemArray[6].ToString().Equals(string.Empty)) { if (decimal.TryParse((row as DataRow).ItemArray[6].ToString(), out value)) { if (value > 0) { documento.ValorAdicion = value; } } } //ValorAPagar if (!(row as DataRow).ItemArray[7].ToString().Equals(string.Empty)) { if (decimal.TryParse((row as DataRow).ItemArray[7].ToString(), out value)) { if (value > 0) { documento.ValorAPagar = value; } } } //ValorPagado if (!(row as DataRow).ItemArray[8].ToString().Equals(string.Empty)) { if (decimal.TryParse((row as DataRow).ItemArray[8].ToString(), out value)) { if (value > 0) { documento.SaldoDisponible = value; } } } documento.EstadoPlanPago = (row as DataRow).ItemArray[9].ToString(); documento.ViaticosDescripcion = (row as DataRow).ItemArray[10].ToString(); //TipoIdentificacionTercero if (!(row as DataRow).ItemArray[11].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[11].ToString(), out numValue)) { documento.TipoIdentificacionTercero = numValue; } } //IdentificacionTercero documento.IdentificacionTercero = (row as DataRow).ItemArray[12].ToString(); //NumeroPago if (!(row as DataRow).ItemArray[13].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[13].ToString(), out numValue)) { if (numValue > 0) { documento.NumeroPago = numValue; } } } //IdentificacionRubroPresupuestal documento.IdentificacionRubroPresupuestal = (row as DataRow).ItemArray[14].ToString(); //IdentificacionUsoPresupuestal documento.IdentificacionUsoPresupuestal = (row as DataRow).ItemArray[15].ToString(); //Proveedor documento.NumeroRadicadoProveedor = (row as DataRow).ItemArray[16].ToString(); if (!(row as DataRow).ItemArray[17].ToString().Equals(string.Empty)) { if (DateTime.TryParse((row as DataRow).ItemArray[17].ToString(), out fecha)) { if (fecha != DateTime.MinValue) { documento.FechaRadicadoProveedor = fecha; } } } //Supervisor documento.NumeroRadicadoSupervisor = (row as DataRow).ItemArray[18].ToString(); if (!(row as DataRow).ItemArray[19].ToString().Equals(string.Empty)) { if (DateTime.TryParse((row as DataRow).ItemArray[19].ToString(), out fecha)) { if (fecha != DateTime.MinValue) { documento.FechaRadicadoSupervisor = fecha; } } } //Factura documento.NumeroFactura = (row as DataRow).ItemArray[20].ToString(); if (!(row as DataRow).ItemArray[21].ToString().Equals(string.Empty)) { if (decimal.TryParse((row as DataRow).ItemArray[21].ToString(), out value)) { if (value > 0) { documento.ValorFacturado = value; } } } //FechaFactura if (!(row as DataRow).ItemArray[23].ToString().Equals(string.Empty)) { if (DateTime.TryParse((row as DataRow).ItemArray[23].ToString(), out fecha)) { if (fecha != DateTime.MinValue) { documento.FechaFactura = fecha; } } } //Observaciones documento.Observaciones = (row as DataRow).ItemArray[22].ToString(); //Obligacion if (!(row as DataRow).ItemArray[24].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[24].ToString(), out numValue)) { if (numValue > 0) { documento.Obligacion = numValue; } } } //OrdenPago if (!(row as DataRow).ItemArray[25].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[25].ToString(), out numValue)) { if (numValue > 0) { documento.OrdenPago = numValue; } } } //EstadoOrdenPago documento.EstadoOrdenPago = (row as DataRow).ItemArray[26].ToString(); //FechaOrdenPago if (!(row as DataRow).ItemArray[27].ToString().Equals(string.Empty)) { if (DateTime.TryParse((row as DataRow).ItemArray[27].ToString(), out fecha)) { if (fecha != DateTime.MinValue) { documento.FechaOrdenPago = fecha; } } } //DiasAlPago if (!(row as DataRow).ItemArray[28].ToString().Equals(string.Empty)) { if (Int32.TryParse((row as DataRow).ItemArray[28].ToString(), out numValue)) { if (numValue > 0) { documento.DiasAlPago = numValue; } } } listaDocumento.Add(documento); } return(listaDocumento); }