public async Task <Response> PutActividadesEsenciales([FromRoute] int id, [FromBody] ActividadesEsenciales ActividadesEsenciales)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe = await db.ActividadesEsenciales
                             .Where(w =>
                                    w.Descripcion.ToString().ToUpper() == ActividadesEsenciales.Descripcion.ToString().ToUpper()
                                    ).FirstOrDefaultAsync();


                if (existe != null && existe.IdActividadesEsenciales != id)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                var ActividadesEsencialesActualizar = await db.ActividadesEsenciales.Where(x => x.IdActividadesEsenciales == id).FirstOrDefaultAsync();

                if (ActividadesEsencialesActualizar != null)
                {
                    try
                    {
                        ActividadesEsencialesActualizar.Descripcion = ActividadesEsenciales.Descripcion.ToString().ToUpper();
                        db.ActividadesEsenciales.Update(ActividadesEsencialesActualizar);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                            Resultado = ActividadesEsencialesActualizar
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                            ExceptionTrace       = ex.Message,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#2
0
        public async Task <Response> PutFormulasRMU([FromRoute] int id, [FromBody] FormulasRMU FormulasRMU)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe = Existe(FormulasRMU);
                if (existe.IsSuccess)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                var FormulasRMUActualizar = await db.FormulasRMU.Where(x => x.IdFormulaRMU == id).FirstOrDefaultAsync();

                if (FormulasRMUActualizar != null)
                {
                    try
                    {
                        FormulasRMUActualizar.Formula = FormulasRMU.Formula;
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                            ExceptionTrace       = ex,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#3
0
        public async Task <Response> PutMaestroArticuloSucursal([FromRoute] int id, [FromBody] MaestroArticuloSucursal maestroArticuloSucursal)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }

                var maestroArticuloSucursalActualizar = await db.MaestroArticuloSucursal.Where(x => x.IdMaestroArticuloSucursal == id).FirstOrDefaultAsync();

                if (maestroArticuloSucursalActualizar != null)
                {
                    try
                    {
                        maestroArticuloSucursalActualizar.Minimo     = maestroArticuloSucursal.Minimo;
                        maestroArticuloSucursalActualizar.Maximo     = maestroArticuloSucursal.Maximo;
                        maestroArticuloSucursalActualizar.IdSucursal = maestroArticuloSucursal.IdSucursal;
                        db.MaestroArticuloSucursal.Update(maestroArticuloSucursalActualizar);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.ModeloInvalido,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwRm),
                            ExceptionTrace       = ex,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#4
0
        public async Task <Response> PutTrabajoEquipoIniciativaLiderazgo([FromRoute] int id, [FromBody] TrabajoEquipoIniciativaLiderazgo TrabajoEquipoIniciativaLiderazgo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe = Existe(TrabajoEquipoIniciativaLiderazgo);
                if (existe.IsSuccess)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                var TrabajoEquipoIniciativaLiderazgoActualizar = await db.TrabajoEquipoIniciativaLiderazgo.Where(x => x.IdTrabajoEquipoIniciativaLiderazgo == id).FirstOrDefaultAsync();

                if (TrabajoEquipoIniciativaLiderazgoActualizar != null)
                {
                    try
                    {
                        TrabajoEquipoIniciativaLiderazgoActualizar.Nombre = TrabajoEquipoIniciativaLiderazgo.Nombre;
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                            ExceptionTrace       = ex.Message,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
        public async Task <Response> PutProvincia([FromRoute] int id, [FromBody] Provincia provincia)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var provinciaActualizar = await db.Provincia.Where(x => x.IdProvincia == id).FirstOrDefaultAsync();

                if (provinciaActualizar != null)
                {
                    try
                    {
                        provinciaActualizar.IdPais = provincia.IdPais;
                        provinciaActualizar.Nombre = provincia.Nombre;
                        db.Provincia.Update(provinciaActualizar);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                            ExceptionTrace       = ex.Message,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#6
0
        public async Task <Response> Login([FromBody] Login login)
        {
            try
            {
                var usuario = db.Adscpassw.Where(x => x.AdpsLogin == login.Usuario).FirstOrDefault();

                if (usuario == null)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.RegistroNoEncontrado
                    });
                }

                if (usuario.AdpsFechaVencimiento < DateTime.Now)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = "Usuario Caducado"
                    });
                }

                if (usuario.AdpsIntentos >= 3)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = "Usuario Bloqueado contacte con el administrador"
                    });
                }



                var existeLogin = db.Adscpassw.Where(x => x.AdpsLogin == login.Usuario && x.AdpsPassword == login.Contrasena).FirstOrDefault();
                if (existeLogin == null)
                {
                    usuario.AdpsIntentos    = usuario.AdpsIntentos + 1;
                    db.Entry(usuario).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(new Response
                    {
                        IsSuccess = false,
                        Message = "No existe",
                        Resultado = "",
                    });
                }
                return(new Response
                {
                    IsSuccess = true,
                    Message = "Ok",
                    Resultado = existeLogin,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwSeguridad),
                    ExceptionTrace       = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    Message  = ex.Message,
                    UserName = login.Usuario,
                });

                return(new Response
                {
                    IsSuccess = false,
                    Message = ex.Message,
                });

                throw;
            }
        }
示例#7
0
        public async Task <Response> PutCatalogoCuenta([FromRoute] int id, [FromBody] CatalogoCuenta catalogoCuenta)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }

                var catalogoCuentaActualizar = await db.CatalogoCuenta.Where(x => x.IdCatalogoCuenta == id).FirstOrDefaultAsync();

                if (catalogoCuentaActualizar != null)
                {
                    try
                    {
                        catalogoCuentaActualizar.Codigo = catalogoCuenta.Codigo;
                        catalogoCuentaActualizar.IdCatalogoCuentaHijo = catalogoCuenta.IdCatalogoCuentaHijo;
                        db.CatalogoCuenta.Update(catalogoCuentaActualizar);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwRm),
                            ExceptionTrace       = ex,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
        public async Task <Response> PutConfiguracionViatico([FromRoute] int id, [FromBody] ConfiguracionViatico ConfiguracionViatico)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }


                var existe = Existe(ConfiguracionViatico);
                var ConfiguracionViaticoActualizar = (ConfiguracionViatico)existe.Resultado;

                if (existe.IsSuccess)
                {
                    if (ConfiguracionViaticoActualizar.IdConfiguracionViatico == ConfiguracionViatico.IdConfiguracionViatico)
                    {
                        if (ConfiguracionViatico.IdDependencia == ConfiguracionViaticoActualizar.IdDependencia &&
                            ConfiguracionViatico.ValorEntregadoPorDia == ConfiguracionViaticoActualizar.ValorEntregadoPorDia &&
                            ConfiguracionViatico.PorCientoAJustificar == ConfiguracionViaticoActualizar.PorCientoAJustificar)
                        {
                            return(new Response
                            {
                                IsSuccess = true,
                            });
                        }

                        await Actualizar(ConfiguracionViatico);

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                await Actualizar(ConfiguracionViatico);

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Excepcion,
                });
            }
        }
        public async Task <Response> PutFormularioDevengacion([FromRoute] int id, [FromBody] FormularioDevengacion FormularioDevengacion)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = "Módelo inválido"
                    });
                }

                var existe = Existe(FormularioDevengacion);
                if (existe.IsSuccess)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = "Existe un registro de igual modo social",
                    });
                }

                var FormularioDevengacionActualizar = await db.FormularioDevengacion.Where(x => x.IdFormularioDevengacion == id).FirstOrDefaultAsync();

                if (FormularioDevengacionActualizar != null)
                {
                    try
                    {
                        FormularioDevengacionActualizar.ModoSocial = FormularioDevengacion.ModoSocial;
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = "Ok",
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                            ExceptionTrace       = ex.Message,
                            Message              = "Se ha producido una excepción",
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = "Error ",
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = "Existe"
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = "Excepción"
                });
            }
        }
        public async Task <List <SolicitudProveeduriaDetalle> > GetSolicitudProveeduria()
        {
            try
            {
                //return await db.SolicitudProveeduriaDetalle.OrderBy(x => x.IdSolicitudProveeduriaDetalle).Include(c=> c).ToListAsync();

                return(await(from solProv in db.SolicitudProveeduria
                             join solProvDet in db.SolicitudProveeduriaDetalle on solProv.IdSolicitudProveeduria equals solProvDet.IdSolicitudProveeduria
                             join empl in db.Empleado on solProv.IdEmpleado equals empl.IdEmpleado
                             join pers in db.Persona on empl.IdPersona equals pers.IdPersona
                             join art in db.Articulo on solProvDet.IdArticulo equals art.IdArticulo
                             join est in db.Estado on solProvDet.IdEstado equals est.IdEstado

                             select new SolicitudProveeduriaDetalle
                {
                    CantidadAprobada = solProvDet.CantidadAprobada,
                    CantidadSolicitada = solProvDet.CantidadSolicitada,
                    FechaAprobada = solProvDet.FechaAprobada,
                    FechaSolicitud = solProvDet.FechaSolicitud,
                    IdMaestroArticuloSucursal = solProvDet.IdMaestroArticuloSucursal,
                    IdSolicitudProveeduria = solProv.IdSolicitudProveeduria,
                    IdArticulo = art.IdArticulo,
                    IdEstado = est.IdEstado,
                    IdSolicitudProveeduriaDetalle = solProvDet.IdSolicitudProveeduriaDetalle,
                    Articulo = new Articulo
                    {
                        IdArticulo = solProvDet.IdArticulo,
                        Nombre = art.Nombre
                    },
                    Estado = new Estado
                    {
                        IdEstado = solProvDet.IdEstado,
                        Nombre = est.Nombre
                    },
                    SolicitudProveeduria = new SolicitudProveeduria
                    {
                        IdSolicitudProveeduria = solProv.IdSolicitudProveeduria,
                        IdEmpleado = empl.IdEmpleado,
                        Empleado = new Empleado
                        {
                            IdEmpleado = solProv.IdEmpleado,
                            IdPersona = empl.IdPersona,
                            Persona = new Persona
                            {
                                IdPersona = empl.IdPersona,
                                Nombres = pers.Nombres,
                                Apellidos = pers.Apellidos
                            }
                        }
                    }
                }
                             ).Where(c => c.Estado.Nombre == "Baja Solicitada").ToListAsync());
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwRm),
                    ExceptionTrace       = ex,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new List <SolicitudProveeduriaDetalle>());
            }
        }
示例#11
0
        public async Task <Response> PutInstitucionFinanciera([FromRoute] int id, [FromBody] InstitucionFinanciera InstitucionFinanciera)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }



                var existe = db.InstitucionFinanciera
                             .Where(w =>
                                    w.IdInstitucionFinanciera != id &&
                                    (
                                        w.Nombre.ToString().ToUpper() == InstitucionFinanciera.Nombre.ToString().ToUpper() ||
                                        w.SPI == InstitucionFinanciera.SPI
                                    )
                                    )
                             .ToList()
                ;


                if
                (
                    existe.Count > 0
                )
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                // convertir a mayúsculas
                InstitucionFinanciera.Nombre = InstitucionFinanciera.Nombre.ToString().ToUpper();

                await Actualizar(InstitucionFinanciera);

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.GuardadoSatisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex.Message,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Excepcion,
                });
            }
        }
        public async Task <Response> PutSolicitudProveeduriaDetalle([FromRoute] int id, [FromBody] SolicitudProveeduriaDetalle SolicitudProveeduriaDetalle)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }

                var SolicitudProveeduriaDetalleActualizar = await db.SolicitudProveeduriaDetalle.Where(x => x.IdSolicitudProveeduriaDetalle == id).FirstOrDefaultAsync();

                if (SolicitudProveeduriaDetalleActualizar != null)
                {
                    try
                    {
                        SolicitudProveeduriaDetalleActualizar.IdSolicitudProveeduriaDetalle = SolicitudProveeduriaDetalle.IdSolicitudProveeduriaDetalle;
                        SolicitudProveeduriaDetalleActualizar.IdMaestroArticuloSucursal     = SolicitudProveeduriaDetalle.IdMaestroArticuloSucursal;
                        SolicitudProveeduriaDetalleActualizar.IdArticulo             = SolicitudProveeduriaDetalle.IdArticulo;
                        SolicitudProveeduriaDetalleActualizar.IdSolicitudProveeduria = SolicitudProveeduriaDetalle.IdSolicitudProveeduria;
                        SolicitudProveeduriaDetalleActualizar.CantidadAprobada       = SolicitudProveeduriaDetalle.CantidadAprobada;
                        SolicitudProveeduriaDetalleActualizar.CantidadSolicitada     = SolicitudProveeduriaDetalle.CantidadSolicitada;
                        SolicitudProveeduriaDetalleActualizar.FechaAprobada          = SolicitudProveeduriaDetalle.FechaAprobada;
                        SolicitudProveeduriaDetalleActualizar.FechaSolicitud         = SolicitudProveeduriaDetalle.FechaSolicitud;
                        SolicitudProveeduriaDetalleActualizar.IdEstado = SolicitudProveeduriaDetalle.IdEstado;
                        db.SolicitudProveeduriaDetalle.Update(SolicitudProveeduriaDetalleActualizar);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwRm),
                            ExceptionTrace       = ex,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#13
0
        public async Task <Response> PutAdscgrp([FromBody] Adscgrp adscgrp)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var adscgrpSeleccionado = await db.Adscgrp.SingleOrDefaultAsync(m => m.AdgrGrupo == adscgrp.AdgrGrupo && m.AdgrBdd == adscgrp.AdgrBdd);

                if (adscgrpSeleccionado != null)
                {
                    try
                    {
                        adscgrpSeleccionado.AdgrNombre      = adscgrp.AdgrNombre;
                        adscgrpSeleccionado.AdgrDescripcion = adscgrp.AdgrDescripcion;
                        db.Adscgrp.Update(adscgrpSeleccionado);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwSeguridad),
                            ExceptionTrace       = ex,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#14
0
        public async Task <IActionResult> Create(SolicitudHorasExtras solicitudhorasextra)
        {
            if (ModelState.IsValid)
            {
                InicializarMensaje(null);
                return(View(solicitudhorasextra));
            }

            Response response = new Response();

            try
            {
                var claim         = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault();
                var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value;
                var empleadoJson  = ObtenerEmpleadoLogueado(NombreUsuario);
                //var empleado = JsonConvert.DeserializeObject<Empleado>(empleadoJson.ToString());
                solicitudhorasextra.IdEmpleado     = empleadoJson.Result.IdEmpleado;
                solicitudhorasextra.FechaSolicitud = DateTime.Now;
                solicitudhorasextra.Estado         = 0;
                var HorasExtra = new SolicitudHorasExtras
                {
                    Fecha = solicitudhorasextra.Fecha,
                };
                var resultado = await apiServicio.ObtenerElementoAsync1 <Response>(HorasExtra, new Uri(WebApp.BaseAddress), "api/SolicitudHorasExtras/EsExtraordinaria");

                solicitudhorasextra.EsExtraordinaria = false;
                if (resultado.IsSuccess)
                {
                    solicitudhorasextra.EsExtraordinaria = true;
                }


                response = await apiServicio.InsertarAsync(solicitudhorasextra,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/SolicitudHorasExtras/InsertarSolicitudHorasExtras");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado una Solicitud de Horas Extra",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Solicitud Horas Extras:", solicitudhorasextra.IdSolicitudHorasExtras),
                    });

                    return(RedirectToAction("Index"));
                }

                ViewData["Error"] = response.Message;
                //ViewData["IdBrigadaSSO"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar<BrigadaSSO>(new Uri(WebApp.BaseAddress), "api/BrigadasSSO/ListarBrigadasSSO"), "IdBrigadaSSO", "Nombre");
                return(View(solicitudhorasextra));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando Solicitud Horas Extras",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
示例#15
0
        public async Task <Response> PostEmpleado([FromBody] EmpleadoViewModel empleadoViewModel)
        {
            using (var transaction = await db.Database.BeginTransactionAsync())
            {
                try
                {
                    //Insertar persona y recuperar el Id con el que ha sido insertado
                    var persona = await db.Persona.AddAsync(empleadoViewModel.Persona);

                    await db.SaveChangesAsync();

                    //Insertar empleado con el Id persona recuperado y recuperar el Id de Empleado

                    empleadoViewModel.Empleado.IdPersona = persona.Entity.IdPersona;

                    var empleado = await db.Empleado.AddAsync(empleadoViewModel.Empleado);

                    await db.SaveChangesAsync();

                    ////Insertar datos bancarios del empleado insertado con aterioridad
                    //empleadoViewModel.DatosBancarios.IdEmpleado = empleado.Entity.IdEmpleado;

                    //await db.DatosBancarios.AddAsync(empleadoViewModel.DatosBancarios);
                    //await db.SaveChangesAsync();


                    ////Insertar familiares del empleado

                    //foreach (var empleadoFamiliar in empleadoViewModel.EmpleadoFamiliar)
                    //{
                    //    //Insertar persona familiar y obtener su id
                    //    var personafamiliar = await db.Persona.AddAsync(empleadoFamiliar.Persona);
                    //    await db.SaveChangesAsync();

                    //    //insertar EmpleadoFamiliar  con el Id de persona insertada anteriormente
                    //    empleadoFamiliar.IdEmpleado = empleado.Entity.IdEmpleado;
                    //    await db.EmpleadoFamiliar.AddAsync(empleadoFamiliar);
                    //    await db.SaveChangesAsync();

                    //}

                    transaction.Commit();

                    return(new Response
                    {
                        IsSuccess = true,
                        Message = Mensaje.Satisfactorio,
                    });
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                        ExceptionTrace       = ex,
                        Message              = Mensaje.Excepcion,
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                        UserName             = "",
                    });

                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.Error,
                    });
                }
            }
        }
示例#16
0
        public async Task <Response> PutRubro([FromRoute] int id, [FromBody] Rubro Rubro)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }


                var existe          = Existe(Rubro);
                var RubroActualizar = (Rubro)existe.Resultado;

                if (existe.IsSuccess)
                {
                    if (RubroActualizar.IdRubro == Rubro.IdRubro)
                    {
                        if (Rubro.Nombre == RubroActualizar.Nombre &&
                            Rubro.TasaPorcentualMaxima == RubroActualizar.TasaPorcentualMaxima)
                        {
                            return(new Response
                            {
                                IsSuccess = true,
                            });
                        }

                        await Actualizar(Rubro);

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                await Actualizar(Rubro);

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex.Message,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Excepcion,
                });
            }
        }
示例#17
0
        public async Task <Response> PutAdscpassw([FromRoute] string id, [FromBody] Adscpassw adscpassw)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var adscPsswActualizar = await db.Adscpassw.Where(x => x.AdpsLogin == id).FirstOrDefaultAsync();

                if (adscPsswActualizar != null)
                {
                    try
                    {
                        adscPsswActualizar.AdpsPreguntaRecuperacion  = adscpassw.AdpsPreguntaRecuperacion;
                        adscPsswActualizar.AdpsRespuestaRecuperacion = adscpassw.AdpsRespuestaRecuperacion;
                        db.Adscpassw.Update(adscPsswActualizar);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwSeguridad),
                            ExceptionTrace       = ex,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#18
0
        public async Task <Response> PutEmpleadoContactoEmergencia([FromRoute] int id, [FromBody] EmpleadoFamiliarViewModel empleadoFamiliarViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var PersonaActual = await db.Persona.Where(x => x.IdPersona == empleadoFamiliarViewModel.IdPersona).FirstOrDefaultAsync();

                var existe = Existe(empleadoFamiliarViewModel);
                if (existe.IsSuccess)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }
                else
                {
                    using (var transaction = await db.Database.BeginTransactionAsync())
                    {
                        try
                        {
                            //1. Actualizar Persona
                            PersonaActual.Nombres         = empleadoFamiliarViewModel.Nombres;
                            PersonaActual.Apellidos       = empleadoFamiliarViewModel.Apellidos;
                            PersonaActual.TelefonoPrivado = empleadoFamiliarViewModel.TelefonoPrivado;
                            PersonaActual.TelefonoCasa    = empleadoFamiliarViewModel.TelefonoCasa;
                            PersonaActual.CorreoPrivado   = empleadoFamiliarViewModel.CorreoPrivado;


                            //2. Actualizar EmpleadoContactoEmergencia
                            var EmpleadoContactoEmergenciaActualizar = await db.EmpleadoContactoEmergencia.Where(x => x.IdPersona == empleadoFamiliarViewModel.IdPersona).FirstOrDefaultAsync();

                            EmpleadoContactoEmergenciaActualizar.IdPersona    = empleadoFamiliarViewModel.IdPersona;
                            EmpleadoContactoEmergenciaActualizar.IdEmpleado   = empleadoFamiliarViewModel.IdEmpleado;
                            EmpleadoContactoEmergenciaActualizar.IdParentesco = empleadoFamiliarViewModel.IdParentesco;

                            await db.SaveChangesAsync();


                            transaction.Commit();

                            return(new Response
                            {
                                IsSuccess = true,
                                Message = Mensaje.Satisfactorio,
                            });
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();
                            await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                            {
                                ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                                ExceptionTrace       = ex.Message,
                                Message              = Mensaje.Excepcion,
                                LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                                LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                                UserName             = "",
                            });

                            return(new Response
                            {
                                IsSuccess = false,
                                Message = Mensaje.Error,
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Error,
                });
            }
        }
示例#19
0
        public async Task <Response> PutInstitucionFinanciera([FromRoute] int id, [FromBody] InstitucionFinanciera InstitucionFinanciera)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }



                var existe = Existe(InstitucionFinanciera);
                var InstitucionFinancieraActualizar = (InstitucionFinanciera)existe.Resultado;

                if (existe.IsSuccess)
                {
                    if (InstitucionFinancieraActualizar.IdInstitucionFinanciera == InstitucionFinanciera.IdInstitucionFinanciera)
                    {
                        if (
                            InstitucionFinanciera.Nombre == InstitucionFinancieraActualizar.Nombre &&
                            InstitucionFinanciera.SPI == InstitucionFinancieraActualizar.SPI)
                        {
                            return(new Response
                            {
                                IsSuccess = true,
                            });
                        }

                        await Actualizar(InstitucionFinanciera);

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                await Actualizar(InstitucionFinanciera);

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Excepcion,
                });
            }
        }
示例#20
0
        public async Task <Response> PutPaquetesInformaticos([FromRoute] int id, [FromBody] PaquetesInformaticos PaquetesInformaticos)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }


                var existe = Existe(PaquetesInformaticos);
                var PaquetesInformaticosActualizar = (PaquetesInformaticos)existe.Resultado;

                if (existe.IsSuccess)
                {
                    if (PaquetesInformaticosActualizar.IdPaquetesInformaticos == PaquetesInformaticos.IdPaquetesInformaticos)
                    {
                        if (PaquetesInformaticos.Nombre == PaquetesInformaticosActualizar.Nombre &&
                            PaquetesInformaticos.Descripcion == PaquetesInformaticosActualizar.Descripcion)
                        {
                            return(new Response
                            {
                                IsSuccess = true,
                            });
                        }

                        await Actualizar(PaquetesInformaticos);

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                await Actualizar(PaquetesInformaticos);

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Excepcion,
                });
            }
        }
示例#21
0
        public async Task <Response> PostCatalogoCuenta([FromBody] CatalogoCuenta catalogoCuenta)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var respuesta = Existe(catalogoCuenta);
                if (!respuesta.IsSuccess)
                {
                    db.CatalogoCuenta.Add(catalogoCuenta);
                    await db.SaveChangesAsync();

                    if (catalogoCuenta.IdCatalogoCuentaHijo == 0)
                    {
                        catalogoCuenta = db.CatalogoCuenta.FirstOrDefault();
                        if (catalogoCuenta != null)
                        {
                            catalogoCuenta.IdCatalogoCuentaHijo = catalogoCuenta.IdCatalogoCuenta;
                            await db.SaveChangesAsync();
                        }
                    }

                    return(new Response
                    {
                        IsSuccess = true,
                        Message = Mensaje.Satisfactorio
                    });
                }

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwRm),
                    ExceptionTrace       = ex,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Error,
                });
            }
        }
示例#22
0
        public async Task <Response> PutSolicitudViatico([FromRoute] int id, [FromBody] SolicitudViatico solicitudViatico)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe = Existe(solicitudViatico);
                if (existe.IsSuccess)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                var solicitudViaticoActualizar = await db.SolicitudViatico.Where(x => x.IdSolicitudViatico == id).FirstOrDefaultAsync();

                if (solicitudViaticoActualizar != null)
                {
                    try
                    {
                        solicitudViaticoActualizar.IdEmpleado             = solicitudViatico.IdEmpleado;
                        solicitudViaticoActualizar.IdCiudad               = solicitudViatico.IdCiudad;
                        solicitudViaticoActualizar.IdConfiguracionViatico = solicitudViatico.IdConfiguracionViatico;
                        solicitudViaticoActualizar.FechaSolicitud         = solicitudViatico.FechaSolicitud;
                        solicitudViaticoActualizar.Descripcion            = solicitudViatico.Descripcion;
                        solicitudViaticoActualizar.ValorEstimado          = solicitudViatico.ValorEstimado;
                        solicitudViaticoActualizar.FechaLlegada           = solicitudViatico.FechaLlegada;
                        solicitudViaticoActualizar.FechaSalida            = solicitudViatico.FechaSalida;
                        solicitudViaticoActualizar.Observacion            = solicitudViatico.Observacion;
                        solicitudViaticoActualizar.Estado = solicitudViatico.Estado;
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                            ExceptionTrace       = ex.Message,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#23
0
        public async Task <Response> PutTipoNombramiento([FromRoute] int id, [FromBody] TipoNombramiento TipoNombramiento)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe = Existe(TipoNombramiento);
                var TipoNombramientoActualizar = (TipoNombramiento)existe.Resultado;
                if (existe.IsSuccess)
                {
                    if (TipoNombramientoActualizar.IdTipoNombramiento == TipoNombramiento.IdTipoNombramiento)
                    {
                        return(new Response
                        {
                            IsSuccess = true,
                        });
                    }
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }
                var tiponombramiento = db.TipoNombramiento.Find(TipoNombramiento.IdTipoNombramiento);

                tiponombramiento.IdRelacionLaboral = TipoNombramiento.IdRelacionLaboral;
                tiponombramiento.Nombre            = TipoNombramiento.Nombre;
                db.TipoNombramiento.Update(tiponombramiento);
                await db.SaveChangesAsync();

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex.Message,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Excepcion,
                });
            }
        }
示例#24
0
        public async Task <Response> DeleteSolicitudViatico([FromRoute] int id)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }
                var respuesta1 = await db.SolicitudTipoViatico.SingleOrDefaultAsync(m => m.IdSolicitudViatico == id);

                if (respuesta1 == null)
                {
                    var respuesta2 = await db.SolicitudViatico.SingleOrDefaultAsync(m => m.IdSolicitudViatico == id);

                    if (respuesta2 == null)
                    {
                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.RegistroNoEncontrado,
                        });
                    }
                    db.SolicitudViatico.Remove(respuesta2);
                    await db.SaveChangesAsync();
                }
                else
                {
                    db.SolicitudTipoViatico.Remove(respuesta1);
                    var respuesta = await db.SolicitudViatico.SingleOrDefaultAsync(m => m.IdSolicitudViatico == id);

                    if (respuesta == null)
                    {
                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.RegistroNoEncontrado,
                        });
                    }
                    db.SolicitudViatico.Remove(respuesta);
                    await db.SaveChangesAsync();
                }
                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex.Message,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Error,
                });
            }
        }
        public async Task <Response> PutEmpleadoActivoFijo([FromRoute] int id, [FromBody] EmpleadoActivoFijo empleadoActivoFijo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }

                var empleadoActivoFijoActualizar = await db.EmpleadoActivoFijo.Where(x => x.IdEmpleadoActivoFijo == id).FirstOrDefaultAsync();

                if (empleadoActivoFijoActualizar != null)
                {
                    try
                    {
                        empleadoActivoFijoActualizar.FechaAsignacion = empleadoActivoFijo.FechaAsignacion;
                        empleadoActivoFijoActualizar.IdActivoFijo    = empleadoActivoFijo.IdActivoFijo;
                        empleadoActivoFijoActualizar.IdEmpleado      = empleadoActivoFijo.IdEmpleado;

                        db.EmpleadoActivoFijo.Update(empleadoActivoFijoActualizar);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.ModeloInvalido,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwRm),
                            ExceptionTrace       = ex,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#26
0
        public async Task <IActionResult> Index(int IdPlanGestionCambio, int IdActividadesGestionCambio)
        {
            try
            {
                if (IdPlanGestionCambio != 0 && IdActividadesGestionCambio == 0)
                {
                    var actividadesGestionCambio = new ActividadesGestionCambioViewModel
                    {
                        IdPlanGestionCambio = Convert.ToInt32(IdPlanGestionCambio),
                    };

                    var viewModelActividadesGestionCambio = new ActividadesGestionCambioViewModel
                    {
                        IdPlanGestionCambio           = Convert.ToInt32(IdPlanGestionCambio),
                        ListaActividadesGestionCambio = await apiServicio.Listar <ActividadesGestionCambioIndex>(actividadesGestionCambio, new Uri(WebApp.BaseAddress), "/api/ActividadesGestionCambio/ListarActividadesGestionCambioconIdPlan")
                    };

                    return(View(viewModelActividadesGestionCambio));
                }

                if (IdPlanGestionCambio == 0 && IdActividadesGestionCambio != 0)
                {
                    var actividadesGestionCambio = new ActividadesGestionCambio
                    {
                        IdActividadesGestionCambio = Convert.ToInt32(IdActividadesGestionCambio),
                    };


                    var respuesta = await apiServicio.ObtenerElementoAsync <ActividadesGestionCambio>(actividadesGestionCambio, new Uri(WebApp.BaseAddress),
                                                                                                      "/api/ActividadesGestionCambio/ActividadesGestionCambioconIdActividad");

                    var actividades = JsonConvert.DeserializeObject <ActividadesGestionCambio>(respuesta.Resultado.ToString());

                    var actividadesGestionCambioViewModel = new ActividadesGestionCambioViewModel
                    {
                        IdPlanGestionCambio = Convert.ToInt32(actividades.IdPlanGestionCambio),
                    };


                    var viewModelActividadesGestionCambio = new ActividadesGestionCambioViewModel
                    {
                        IdPlanGestionCambio           = Convert.ToInt32(actividades.IdPlanGestionCambio),
                        ListaActividadesGestionCambio = await apiServicio.Listar <ActividadesGestionCambioIndex>(actividadesGestionCambioViewModel, new Uri(WebApp.BaseAddress), "/api/ActividadesGestionCambio/ListarActividadesGestionCambioconIdPlan")
                    };


                    return(View(viewModelActividadesGestionCambio));
                }


                ViewData["Mensaje"] = "Ir a la página de Plan Gestión Cambio";
                return(View("NoExisteElemento"));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Listando una actividad de gestión de cambio",
                    ExceptionTrace       = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.NetActivity),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
        public async Task <Response> PutCapacitacionProveedor([FromRoute] int id, [FromBody] CapacitacionProveedor capacitacionProveedor)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe = Existe(capacitacionProveedor);
                if (existe.IsSuccess)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                var capacitacionProveedorActualizar = await db.CapacitacionProveedor.Where(x => x.IdCapacitacionProveedor == id).FirstOrDefaultAsync();

                if (capacitacionProveedorActualizar != null)
                {
                    try
                    {
                        capacitacionProveedorActualizar.Nombre    = capacitacionProveedor.Nombre;
                        capacitacionProveedorActualizar.IdPais    = capacitacionProveedor.IdPais;
                        capacitacionProveedorActualizar.Telefono  = capacitacionProveedor.Telefono;
                        capacitacionProveedorActualizar.Direccion = capacitacionProveedor.Direccion;
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                            ExceptionTrace       = ex.Message,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }
示例#28
0
        public async Task <Response> PutPieFirma([FromRoute] int id, [FromBody] PieFirma pieFirma)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe             = Existe(pieFirma);
                var PieFirmaActualizar = (PieFirma)existe.Resultado;
                if (existe.IsSuccess)
                {
                    if (PieFirmaActualizar.IdPieFirma == pieFirma.IdPieFirma)
                    {
                        return(new Response
                        {
                            IsSuccess = true,
                        });
                    }
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }
                var PieFirma = db.PieFirma.Find(pieFirma.IdPieFirma);

                PieFirma.IdTipoAccionPersonal = pieFirma.IdTipoAccionPersonal;
                PieFirma.IdIndiceOcupacional  = pieFirma.IdIndiceOcupacional;
                PieFirma.Nivel = pieFirma.Nivel;
                db.PieFirma.Update(PieFirma);
                await db.SaveChangesAsync();

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex.Message,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Excepcion,
                });
            }
        }
示例#29
0
        private async Task <bool> SalvarLog(LogEntryTranfer logEntryTranfer)
        {
            var responseLog = await GuardarLogService.SaveLogEntry(logEntryTranfer);

            return(responseLog.IsSuccess);
        }
示例#30
0
        public async Task <Response> PostEmpleado([FromBody] EmpleadoViewModel empleadoViewModel)
        {
            using (var transaction = await db.Database.BeginTransactionAsync())
            {
                try
                {
                    string fechaIndiceOcupacional = empleadoViewModel.IndiceOcupacionalModalidadPartida.Fecha.DayOfWeek.ToString();

                    if (fechaIndiceOcupacional.Equals("Saturday") || fechaIndiceOcupacional.Equals("Sunday"))
                    {
                        return(new Response
                        {
                            IsSuccess = false,
                            Message = "La fecha de tipo de nombramiento no puede ser fin de semana"
                        });
                    }


                    string fechaIngresoEmpleado = empleadoViewModel.Empleado.FechaIngreso.DayOfWeek.ToString();

                    if (fechaIngresoEmpleado.Equals("Saturday") || fechaIngresoEmpleado.Equals("Sunday"))
                    {
                        return(new Response
                        {
                            IsSuccess = false,
                            Message = "La fecha de ingreso a la institución no puede ser fin de semana"
                        });
                    }

                    string fechaIngresoSectorPublico = empleadoViewModel.Empleado.FechaIngresoSectorPublico.DayOfWeek.ToString();

                    if (fechaIngresoSectorPublico.Equals("Saturday") || fechaIngresoSectorPublico.Equals("Sunday"))
                    {
                        return(new Response
                        {
                            IsSuccess = false,
                            Message = "La fecha de ingreso al sector público no puede ser fin de semana"
                        });
                    }

                    if (empleadoViewModel.Empleado.FechaIngresoSectorPublico > empleadoViewModel.Empleado.FechaIngreso)
                    {
                        return(new Response
                        {
                            IsSuccess = false,
                            Message = "La fecha de ingreso del sector público no puede ser mayor que la fecha de ingreso"
                        });
                    }

                    foreach (var trayectoria in empleadoViewModel.TrayectoriaLaboral)
                    {
                        if (trayectoria.FechaInicio <= DateTime.Today)
                        {
                            return(new Response
                            {
                                IsSuccess = false,
                                Message = "La fecha inicio no puede ser menor o igual que la fecha de hoy"
                            });
                        }

                        if (trayectoria.FechaFin <= DateTime.Today)
                        {
                            return(new Response
                            {
                                IsSuccess = false,
                                Message = "La fecha inicio no puede ser menor o igual que la fecha de hoy"
                            });
                        }


                        if (trayectoria.FechaInicio > trayectoria.FechaFin)
                        {
                            return(new Response
                            {
                                IsSuccess = false,
                                Message = "La fecha de inicio no puede ser mayor que la fecha fin"
                            });
                        }

                        string fechaInicio = trayectoria.FechaInicio.DayOfWeek.ToString();

                        if (fechaInicio.Equals("Saturday") || fechaInicio.Equals("Sunday"))
                        {
                            return(new Response
                            {
                                IsSuccess = false,
                                Message = "La fecha de inicio no puede ser fin de semana"
                            });
                        }


                        string fechaFin = trayectoria.FechaFin.DayOfWeek.ToString();

                        if (fechaFin.Equals("Saturday") || fechaFin.Equals("Sunday"))
                        {
                            return(new Response
                            {
                                IsSuccess = false,
                                Message = "La fecha fin no puede ser fin de semana"
                            });
                        }
                    }



                    //1. Insertar Persona
                    var persona = await db.Persona.AddAsync(empleadoViewModel.Persona);

                    await db.SaveChangesAsync();

                    //2. Insertar Empleado (Inicializado : IdPersona, IdDependencia)
                    empleadoViewModel.Empleado.IdPersona     = persona.Entity.IdPersona;
                    empleadoViewModel.Empleado.IdDependencia = 1;
                    var empleado = await db.Empleado.AddAsync(empleadoViewModel.Empleado);

                    await db.SaveChangesAsync();

                    //3. Insertar Datos Bancarios (Inicializado : IdEmpleado)
                    empleadoViewModel.DatosBancarios.IdEmpleado = empleado.Entity.IdEmpleado;
                    await db.DatosBancarios.AddAsync(empleadoViewModel.DatosBancarios);

                    await db.SaveChangesAsync();

                    //4. Insertar Empleado Contacto Emergencia  (Inicializado : IdPersona, IdEmpleado)
                    empleadoViewModel.EmpleadoContactoEmergencia.IdPersona  = persona.Entity.IdPersona;
                    empleadoViewModel.EmpleadoContactoEmergencia.IdEmpleado = empleado.Entity.IdEmpleado;
                    await db.EmpleadoContactoEmergencia.AddAsync(empleadoViewModel.EmpleadoContactoEmergencia);

                    await db.SaveChangesAsync();

                    //5. Insertar Indice Ocupacional Modalidad Partida  (Inicializado : IdIndiceOcupacional, IdEmpleado)
                    empleadoViewModel.IndiceOcupacionalModalidadPartida.IdIndiceOcupacional = 1;
                    empleadoViewModel.IndiceOcupacionalModalidadPartida.IdEmpleado          = 1;
                    await db.IndiceOcupacionalModalidadPartida.AddAsync(empleadoViewModel.IndiceOcupacionalModalidadPartida);

                    await db.SaveChangesAsync();

                    //6. Insertar Persona Estudio (Inicializado : IdPersona)
                    foreach (var personaEstudio in empleadoViewModel.PersonaEstudio)
                    {
                        personaEstudio.IdPersona = persona.Entity.IdPersona;
                        await db.PersonaEstudio.AddAsync(personaEstudio);

                        await db.SaveChangesAsync();
                    }

                    // 7. Insertar Trayectoria Laboral (Inicializado : IdPersona)
                    foreach (var trayectoriaLaboral in empleadoViewModel.TrayectoriaLaboral)
                    {
                        trayectoriaLaboral.IdPersona = persona.Entity.IdPersona;
                        await db.TrayectoriaLaboral.AddAsync(trayectoriaLaboral);

                        await db.SaveChangesAsync();
                    }

                    // 8. Insertar Persona Discapacidad (Inicializado : IdPersona)
                    foreach (var personaDiscapacidad in empleadoViewModel.PersonaDiscapacidad)
                    {
                        personaDiscapacidad.IdPersona = persona.Entity.IdPersona;
                        await db.PersonaDiscapacidad.AddAsync(personaDiscapacidad);

                        await db.SaveChangesAsync();
                    }

                    // 9. Insertar Persona Enfermedad (Inicializado : IdPersona)
                    foreach (var personaEnfermedad in empleadoViewModel.PersonaEnfermedad)
                    {
                        personaEnfermedad.IdPersona = persona.Entity.IdPersona;
                        await db.PersonaEnfermedad.AddAsync(personaEnfermedad);

                        await db.SaveChangesAsync();
                    }

                    // 10. Insertar Persona Sustituto (Inicializado : IdPersona, IdPersonaDiscapacidad)
                    //10.1. Insertar Persona Discapacidad
                    var objetoPersonaSustitutoDiscapacidad = await db.Persona.AddAsync(empleadoViewModel.PersonaSustituto.PersonaDiscapacidad);

                    await db.SaveChangesAsync();

                    // 10.2. Insertar Persona Sustituto
                    empleadoViewModel.PersonaSustituto.IdPersona             = persona.Entity.IdPersona;
                    empleadoViewModel.PersonaSustituto.IdPersonaDiscapacidad = objetoPersonaSustitutoDiscapacidad.Entity.IdPersona;
                    var personaSustituto = empleadoViewModel.PersonaSustituto;
                    await db.PersonaSustituto.AddAsync(empleadoViewModel.PersonaSustituto);

                    await db.SaveChangesAsync();


                    // 10.3. Insertar Discapacidad Sustituto (Inicializado : IdPersonaSustituto)
                    foreach (var discapacidadSustituto in empleadoViewModel.DiscapacidadSustituto)
                    {
                        discapacidadSustituto.IdPersonaSustituto = personaSustituto.IdPersonaSustituto;
                        await db.DiscapacidadSustituto.AddAsync(discapacidadSustituto);

                        await db.SaveChangesAsync();
                    }

                    //10.4. Insertar Enfermedad Sustituto(Inicializado : IdPersonaSustituto)
                    foreach (var enfermedadSustituto in empleadoViewModel.EnfermedadSustituto)
                    {
                        enfermedadSustituto.IdPersonaSustituto = enfermedadSustituto.IdPersonaSustituto;
                        await db.EnfermedadSustituto.AddAsync(enfermedadSustituto);

                        await db.SaveChangesAsync();
                    }

                    // 11.  Insertar Familiares Empleado
                    foreach (var empleadoFamiliar in empleadoViewModel.EmpleadoFamiliar)
                    {
                        //11.1. Insertar Persona
                        var personafamiliar = await db.Persona.AddAsync(empleadoFamiliar.Persona);

                        await db.SaveChangesAsync();

                        //11.2.  Insertar Empleado Familiar (I.icializado : IdPersona, IdEmpleado)
                        empleadoFamiliar.IdEmpleado = empleado.Entity.IdEmpleado;
                        empleadoFamiliar.IdPersona  = personafamiliar.Entity.IdPersona;
                        await db.EmpleadoFamiliar.AddAsync(empleadoFamiliar);

                        await db.SaveChangesAsync();
                    }


                    transaction.Commit();

                    return(new Response
                    {
                        IsSuccess = true,
                        Message = Mensaje.Satisfactorio,
                        Resultado = empleadoViewModel
                    });
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                        ExceptionTrace       = ex,
                        Message              = Mensaje.Excepcion,
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                        UserName             = "",
                    });

                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.Error,
                    });
                }
            }
        }