public async Task <ActionResult> AdicionarCapacitaciones(string idIndiceOcupacional, string mensaje)

        {
            var indiceconocimientoad = new IndiceOcupacionalCapacitaciones
            {
                IdIndiceOcupacional = Convert.ToInt32(idIndiceOcupacional),
            };

            var indiceOcupacional = new IndiceOcupacional
            {
                IdIndiceOcupacional = Convert.ToInt32(idIndiceOcupacional),
            };


            var resultado = await CargarComboCapacitaciones(indiceOcupacional);

            if (resultado)
            {
                InicializarMensaje(mensaje);
                return(PartialView(indiceconocimientoad));
            }

            ViewData["Mensaje"] = Mensaje.NoExistenRegistrosPorAsignar;
            return(PartialView("NoExisteElemento"));
        }
        public async Task <IActionResult> AdicionarCapacitaciones(string id)
        {
            var lista = new List <Capacitacion>();

            try
            {
                var indiceOcupacional = new IndiceOcupacional
                {
                    IdIndiceOcupacional = Convert.ToInt32(id),
                };
                lista = await apiServicio.Listar <Capacitacion>(indiceOcupacional,
                                                                new Uri(WebApp.BaseAddress),
                                                                "/api/IndiceOcupacionalCapacitaciones/ListaFiltradaCapacitaciones");

                ViewData["IdCapacitacion"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(lista, "IdCapacitacion", "Nombre");

                //ViewBag.listacap = new SelectList(lista, "IdCapacitacion", "Nombre");


                var Indice = new IndiceOcupacionalCapacitaciones
                {
                    IdIndiceOcupacional = Convert.ToInt32(id),
                };

                return(PartialView("..//IndicesOcupacionales//AdicionarCapacitaciones", Indice));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
        public async Task <IActionResult> AdicionarCapacitacion(IndiceOcupacionalCapacitaciones indiceOcupacionalCapacitaciones)
        {
            Response response = new Response();

            try
            {
                if (ModelState.IsValid)
                {
                    response = await apiServicio.InsertarAsync(indiceOcupacionalCapacitaciones,
                                                               new Uri(WebApp.BaseAddress),
                                                               "/api/IndicesOcupacionales/InsertarCapacitacion");

                    if (response.IsSuccess)
                    {
                        var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                            ExceptionTrace       = null,
                            Message              = "Se ha creado un indice ocupacional",
                            UserName             = "******",
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                            EntityID             = string.Format("{0} {1} {2} {3}", "Índice ocupacional:", indiceOcupacionalCapacitaciones.IdIndiceOcupacional, "Capacitación:", indiceOcupacionalCapacitaciones.IdCapacitacion),
                        });

                        return(RedirectToAction("Detalles", new { id = indiceOcupacionalCapacitaciones.IdIndiceOcupacional }));
                    }
                }

                var indiceOcupacional = new IndiceOcupacional
                {
                    IdIndiceOcupacional = indiceOcupacionalCapacitaciones.IdIndiceOcupacional,
                };

                await CargarComboCapacitaciones(indiceOcupacional);

                InicializarMensaje(response.Message);
                return(PartialView("AdicionarCapacitaciones", indiceOcupacionalCapacitaciones));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando un Indice ocupacional ",
                    ExceptionTrace       = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
Exemple #4
0
        public async Task <Response> EliminarIndiceOcupacionalCapacitaciones([FromBody] IndiceOcupacionalCapacitaciones indiceOcupacionalCapacitaciones)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }

                var respuesta = await db.IndiceOcupacionalCapacitaciones.SingleOrDefaultAsync(m => m.IdCapacitacion == indiceOcupacionalCapacitaciones.IdCapacitacion && m.IdIndiceOcupacional == indiceOcupacionalCapacitaciones.IdIndiceOcupacional);

                if (respuesta == null)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.RegistroNoEncontrado,
                    });
                }
                db.IndiceOcupacionalCapacitaciones.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,
                });
            }
        }
Exemple #5
0
        public async Task <Response> PostIndiceOcupacionalCapacitaciones([FromBody] IndiceOcupacionalCapacitaciones IndiceOcupacionalCapacitaciones)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = ""
                    });
                }

                var respuesta = Existe(IndiceOcupacionalCapacitaciones);
                if (!respuesta.IsSuccess)
                {
                    db.IndiceOcupacionalCapacitaciones.Add(IndiceOcupacionalCapacitaciones);
                    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.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,
                });
            }
        }
        public async Task <IActionResult> InsertarIndiceOcupacionalCapacitaciones(IndiceOcupacionalCapacitaciones indiceOcupacionalCapacitaciones)
        {
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(indiceOcupacionalCapacitaciones,
                                                           new Uri(WebApp.BaseAddress),
                                                           "/api/IndiceOcupacionalCapacitaciones/InsertarIndiceOcupacionalCapacitacion");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado un Rol de Brigada Salud y Seguridad Ocupacional",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Rol de Brigada Salud y Seguridad Ocupacional:", indiceOcupacionalCapacitaciones.IdIndiceOcupacionalCapacitaciones),
                    });

                    return(RedirectToAction("Detalles", new { id = indiceOcupacionalCapacitaciones.IdIndiceOcupacional }));
                }

                //ViewData["IdIndiceOcupacional"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar<IndiceOcupacional>(new Uri(WebApp.BaseAddress), "/api/IndicesOcupacionales/ListarIndicesOcupacionales"), "IdIndiceOcupacional", "Nombre");
                ViewData["IdCapacitacion"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <Capacitacion>(new Uri(WebApp.BaseAddress), "/api/Capacitaciones/ListarCapacitaciones"), "IdCapacitacion", "Nombre");
                return(View(indiceOcupacionalCapacitaciones));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando Rol de Brigada Salud y Seguridad Ocupacional",
                    ExceptionTrace       = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
        public async Task <IActionResult> AdicionarCapacitaciones(int idCapacitacion, int idIndiceOcupacional)
        {
            Response response = new Response();
            var      indiceOcupacionalCapacitaciones = new IndiceOcupacionalCapacitaciones
            {
                IdCapacitacion = idCapacitacion, IdIndiceOcupacional = idIndiceOcupacional
            };

            response = await apiServicio.InsertarAsync(indiceOcupacionalCapacitaciones,
                                                       new Uri(WebApp.BaseAddress),
                                                       "api/IndicesOcupacionales/InsertarCapacitacion");

            if (response.IsSuccess)
            {
                return(RedirectToAction("NuevoCapacitaciones", new { id = idIndiceOcupacional }));
            }
            return(BadRequest());
        }
        public async Task <IActionResult> EliminarIndiceOcupacionalCapacitaciones(int idCapacitacion, int idIndiceOcupacional)
        {
            try
            {
                var indiceOcupacionalCapacitaciones = new IndiceOcupacionalCapacitaciones
                {
                    IdCapacitacion      = idCapacitacion,
                    IdIndiceOcupacional = idIndiceOcupacional
                };
                var response = await apiServicio.EliminarAsync(indiceOcupacionalCapacitaciones, new Uri(WebApp.BaseAddress)
                                                               , "api/Capacitaciones/EliminarIncideOcupacionalCapacitaciones");

                if (response.IsSuccess)
                {
                    await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName = Convert.ToString(Aplicacion.WebAppTh),
                        EntityID        = string.Format("{0} : {1} {2} {3}", "Capacitaciones ",
                                                        indiceOcupacionalCapacitaciones.IdCapacitacion, "Índice Ocupacional", indiceOcupacionalCapacitaciones.IdIndiceOcupacional),
                        Message = "Registro deActividades esenciales",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Delete),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        UserName             = "******"
                    });

                    return(RedirectToAction("Capacitaciones", "IndicesOcupacionales", new { id = indiceOcupacionalCapacitaciones.IdIndiceOcupacional }));
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Eliminar Area de Conocimiento",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Delete),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
Exemple #9
0
        private Response Existe(IndiceOcupacionalCapacitaciones IndiceOcupacionalCapacitaciones)
        {
            var IndiceOcupacionalCapacitacionesrespuesta = db.IndiceOcupacionalCapacitaciones.Where(p => p.IdIndiceOcupacional == IndiceOcupacionalCapacitaciones.IdIndiceOcupacional && p.IdCapacitacion == IndiceOcupacionalCapacitaciones.IdCapacitacion).FirstOrDefault();

            if (IndiceOcupacionalCapacitacionesrespuesta != null)
            {
                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.ExisteRegistro,
                    Resultado = null,
                });
            }

            return(new Response
            {
                IsSuccess = false,
                Resultado = IndiceOcupacionalCapacitacionesrespuesta,
            });
        }