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

        {
            var indiceEstudio = new IndiceOcupacionalEstudio
            {
                IdIndiceOcupacional = Convert.ToInt32(idIndiceOcupacional),
            };

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


            var resultado = await CargarComboEstudio(indiceOcupacional);

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

            ViewData["Mensaje"] = Mensaje.NoExistenRegistrosPorAsignar;
            return(PartialView("NoExisteElemento"));
        }
        public async Task <IActionResult> AdicionarEstudio(IndiceOcupacionalEstudio indiceOcupacionalEstudio)
        {
            Response response = new Response();

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

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

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

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

                await CargarComboEstudio(indiceOcupacional);

                InicializarMensaje(response.Message);
                return(PartialView("AdicionarEstudio", indiceOcupacionalEstudio));
            }
            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());
            }
        }
Exemplo n.º 3
0
        public async Task <Response> EliminarIncideOcupacionalEstudio([FromBody] IndiceOcupacionalEstudio indiceOcupacionalEstudio)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }

                var respuesta = await db.IndiceOcupacionalEstudio.SingleOrDefaultAsync(m => m.IdEstudio == indiceOcupacionalEstudio.IdEstudio &&
                                                                                       m.IdIndiceOcupacional == indiceOcupacionalEstudio.IdIndiceOcupacional);

                if (respuesta == null)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.RegistroNoEncontrado,
                    });
                }
                db.IndiceOcupacionalEstudio.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 <IActionResult> AdicionarEstudio(int idEstudio, int idIndiceOcupacional)
        {
            Response response = new Response();
            var      indiceOcupacionalEstudio = new IndiceOcupacionalEstudio
            {
                IdEstudio = idEstudio, IdIndiceOcupacional = idIndiceOcupacional
            };

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

            if (response.IsSuccess)
            {
                return(RedirectToAction("NuevoEstudios", new { id = idIndiceOcupacional }));
            }
            return(BadRequest());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> EliminarIndiceOcupacionalEstudios(int idEstudio, int idIndiceOcupacional)
        {
            try
            {
                var indiceOcupacionalEstudio = new IndiceOcupacionalEstudio
                {
                    IdEstudio           = idEstudio,
                    IdIndiceOcupacional = idIndiceOcupacional
                };
                var response = await apiServicio.EliminarAsync(indiceOcupacionalEstudio, new Uri(WebApp.BaseAddress)
                                                               , "/api/Estudios/EliminarIncideOcupacionalEstudio");

                if (response.IsSuccess)
                {
                    await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName = Convert.ToString(Aplicacion.WebAppTh),
                        EntityID        = string.Format("{0} : {1} {2} {3}", "Estudio ",
                                                        indiceOcupacionalEstudio.IdEstudio, "Índice Ocupacional", indiceOcupacionalEstudio.IdIndiceOcupacional),
                        Message = Mensaje.Satisfactorio,
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Delete),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        UserName             = "******"
                    });

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

                return(BadRequest());
            }
        }
Exemplo n.º 6
0
        public async Task <Response> InsertarEstudio([FromBody] IndiceOcupacionalEstudio indiceOcupacionalEstudio)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }
                db.IndiceOcupacionalEstudio.Add(indiceOcupacionalEstudio);
                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,
                });
            }
        }