Ejemplo n.º 1
0
        public async Task <IActionResult> CargarComportamientosObservables(string id)
        {
            var lista = new List <ComportamientoObservable>();

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

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

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


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

                return(PartialView("_PartialViewIndiceOcupacionalComportamientoObservable"));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 2
0
        public async Task <Response> PostIndiceOcupacionalComportamientoObservable([FromBody] IndiceOcupacionalComportamientoObservable IndiceOcupacionalComportamientoObservable)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = ""
                    });
                }

                var respuesta = Existe(IndiceOcupacionalComportamientoObservable);
                if (!respuesta.IsSuccess)
                {
                    db.IndiceOcupacionalComportamientoObservable.Add(IndiceOcupacionalComportamientoObservable);
                    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,
                });
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create(IndiceOcupacionalComportamientoObservable indiceOcupacionalComportamientoObservable)
        {
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(indiceOcupacionalComportamientoObservable,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/IndiceOcupacionalComportamientosObservables/InsertarIndiceOcupacionalComportamientoObservable");

                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:", indiceOcupacionalComportamientoObservable.IdIndiceOcupacionalComportamientoObservable),
                    });

                    return(RedirectToAction("Index"));
                }

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

                return(BadRequest());
            }
        }
        public async Task <IActionResult> EliminarIndiceOcupacionalComportamiemtoObservable(int idComportamientoObservable, int idIndiceOcupacional)
        {
            try
            {
                var indiceOcupacionalComportamientoObservable = new IndiceOcupacionalComportamientoObservable
                {
                    IdComportamientoObservable = idComportamientoObservable,
                    IdIndiceOcupacional        = idIndiceOcupacional
                };
                var response = await apiServicio.EliminarAsync(indiceOcupacionalComportamientoObservable, new Uri(WebApp.BaseAddress)
                                                               , "api/ComportamientosObservables/EliminarIndiceOcupacionalComportamiemtoObservable");

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

                    return(RedirectToAction("ComportamientoObservable", "IndicesOcupacionales", new { id = indiceOcupacionalComportamientoObservable.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());
            }
        }
        public async Task <IActionResult> AdicionarComportamientosObservables(int idIndiceOcupacional, int idComportamientoObservable)
        {
            Response response = new Response();

            var indiceOcupacionalComportamientoObservable = new IndiceOcupacionalComportamientoObservable
            {
                IdComportamientoObservable = idComportamientoObservable,
                IdIndiceOcupacional        = idIndiceOcupacional
            };

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

            if (response.IsSuccess)
            {
                return(RedirectToAction("NuevoComportamientoObservable", new { id = idIndiceOcupacional }));
            }
            return(BadRequest());
        }
Ejemplo n.º 6
0
        private Response Existe(IndiceOcupacionalComportamientoObservable IndiceOcupacionalComportamientoObservable)
        {
            var IndiceOcupacionalComportamientoObservablerespuesta = db.IndiceOcupacionalComportamientoObservable.Where(p => p.IdIndiceOcupacional == IndiceOcupacionalComportamientoObservable.IdIndiceOcupacional && p.IdComportamientoObservable == IndiceOcupacionalComportamientoObservable.IdComportamientoObservable).FirstOrDefault();

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

            return(new Response
            {
                IsSuccess = false,
                Resultado = IndiceOcupacionalComportamientoObservablerespuesta,
            });
        }
Ejemplo n.º 7
0
        public async Task <Response> EliminarIndiceOcupacionalComportamientosObservables([FromBody] IndiceOcupacionalComportamientoObservable indiceOcupacionalComportamientoObservable)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }

                var respuesta = await db.IndiceOcupacionalComportamientoObservable.SingleOrDefaultAsync(m => m.IdComportamientoObservable == indiceOcupacionalComportamientoObservable.IdComportamientoObservable && m.IdIndiceOcupacional == indiceOcupacionalComportamientoObservable.IdIndiceOcupacional);

                if (respuesta == null)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.RegistroNoEncontrado,
                    });
                }
                db.IndiceOcupacionalComportamientoObservable.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,
                });
            }
        }