public ActionResult GrabarGestionDelCambio(EDGestionDelCambio varperfilsocidemografico) { var usuarioActual = ObtenerUsuarioEnSesion(System.Web.HttpContext.Current); if (usuarioActual == null) { ViewBag.mensaje1 = "Debe Registrarse para Ingresar a este Modulo."; return(RedirectToAction("Login", "Home")); } //bool respuestaGuardado = perfilservicio.GrabarPerfilSocioDemografico(perfilsoc,pelsed,inflab); if (varperfilsocidemografico.FK_Tipo_De_Peligro == 8) { varperfilsocidemografico.FK_Clasificacion_De_Peligro = 46; } varperfilsocidemografico.fkempresa = usuarioActual.IdEmpresa; ServiceClient.EliminarParametros(); var result = ServiceClient.RealizarPeticionesPostJsonRestFul <EDGestionDelCambio>(UrlServicioAplicacion, CapacidadCargarGestionDelCambio, varperfilsocidemografico); ServiceClient.AdicionarParametro("idEmpresa", usuarioActual.IdEmpresa); ViewBag.FK_Id_Rol = new SelectList(db.Tbl_Rol, "PK_Id_Rol", "Descripcion"); ViewBag.FK_Tipo_De_Peligro = new SelectList(db.Tbl_Tipo_De_Peligro, "PK_Tipo_De_Peligro", "Descripcion_Del_Peligro"); ViewBag.FK_Clasificacion_De_Peligro = new SelectList(db.Tbl_Clasificacion_De_Peligro, "PK_Clasificacion_De_Peligro", "Descripcion_Clase_De_Peligro"); if (result != null) { ViewBag.Messages2 = "Registro guardado correctamente"; } else { ViewBag.Messages2 = "Se produjo un error al guardar el registro"; } List <EDGestiondelcambioVista> Objlist_RequisitosLegales = new List <EDGestiondelcambioVista>(); return(View("ListadoGestionDelCambio", MostrarGestionDelCambioVista())); }
public HttpResponseMessage GrabarPerfilSocioDemografico(EDGestionDelCambio EDPerfil) { try { LNGestionDelCambio logicas = new LNGestionDelCambio(); var resultado = logicas.GuardarGestionDelCambio(EDPerfil); if (resultado != null) { var response = Request.CreateResponse <EDGestionDelCambio>(HttpStatusCode.Created, resultado); return(response); } else { var response = Request.CreateResponse(HttpStatusCode.ExpectationFailed); return(response); } } catch (Exception ex) { var response = Request.CreateResponse(HttpStatusCode.InternalServerError); return(response); } }
public EDGestionDelCambio GuardarGestionDelCambio(EDGestionDelCambio perfilsoc) { EDGestionDelCambio mp = em.GuardarGestionDelCambio(perfilsoc); return(mp); }
public EDGestionDelCambio GuardarGestionDelCambio(EDGestionDelCambio GestionCambio) { GestionDelCambio acccam = new GestionDelCambio(); acccam.Fecha = GestionCambio.Fecha; acccam.DescripcionDeCambio = GestionCambio.DescripcionDeCambio; acccam.FK_Clasificacion_De_Peligro = GestionCambio.FK_Clasificacion_De_Peligro; acccam.FK_Tipo_De_Peligro = GestionCambio.FK_Tipo_De_Peligro; acccam.RequisitoLegal = GestionCambio.RequisitoLegal; acccam.Recomendaciones = GestionCambio.Recomendaciones; acccam.FechaEjecucion = GestionCambio.FechaEjecucion; acccam.FechaSeguimiento = GestionCambio.FechaSeguimiento; acccam.FK_Id_Rol = GestionCambio.FK_Id_Rol; acccam.FK_Empresa = GestionCambio.fkempresa; acccam.Otro = GestionCambio.Otro; try { using (SG_SSTContext db1 = new SG_SSTContext()) { if (GestionCambio.PK_GestionDelCambio > 0) { if (GestionCambio.FK_Tipo_De_Peligro != 8 && GestionCambio.FK_Clasificacion_De_Peligro != 46) { GestionDelCambio ObregLeg = db1.Tbl_GestionDelCambio.Where(g => g.PK_GestionDelCambio == GestionCambio.PK_GestionDelCambio).FirstOrDefault(); ObregLeg.Fecha = ObregLeg.Fecha; ObregLeg.DescripcionDeCambio = GestionCambio.DescripcionDeCambio; ObregLeg.FK_Clasificacion_De_Peligro = GestionCambio.FK_Clasificacion_De_Peligro; ObregLeg.FK_Tipo_De_Peligro = GestionCambio.FK_Tipo_De_Peligro; ObregLeg.RequisitoLegal = GestionCambio.RequisitoLegal; ObregLeg.Recomendaciones = GestionCambio.Recomendaciones; ObregLeg.FechaEjecucion = GestionCambio.FechaEjecucion; ObregLeg.FechaSeguimiento = GestionCambio.FechaSeguimiento; ObregLeg.FK_Id_Rol = GestionCambio.FK_Id_Rol; ObregLeg.FK_Empresa = GestionCambio.fkempresa; ObregLeg.Otro = ""; db1.Entry(ObregLeg).State = EntityState.Modified; db1.SaveChanges(); } else if (GestionCambio.FK_Tipo_De_Peligro == 8 && GestionCambio.FK_Clasificacion_De_Peligro == 46) { GestionDelCambio ObregLeg = db1.Tbl_GestionDelCambio.Where(g => g.PK_GestionDelCambio == GestionCambio.PK_GestionDelCambio).FirstOrDefault(); ObregLeg.Fecha = ObregLeg.Fecha; ObregLeg.DescripcionDeCambio = GestionCambio.DescripcionDeCambio; ObregLeg.FK_Clasificacion_De_Peligro = GestionCambio.FK_Clasificacion_De_Peligro; ObregLeg.FK_Tipo_De_Peligro = GestionCambio.FK_Tipo_De_Peligro; ObregLeg.RequisitoLegal = GestionCambio.RequisitoLegal; ObregLeg.Recomendaciones = GestionCambio.Recomendaciones; ObregLeg.FechaEjecucion = GestionCambio.FechaEjecucion; ObregLeg.FechaSeguimiento = GestionCambio.FechaSeguimiento; ObregLeg.FK_Id_Rol = GestionCambio.FK_Id_Rol; ObregLeg.FK_Empresa = GestionCambio.fkempresa; ObregLeg.Otro = GestionCambio.Otro; db1.Entry(ObregLeg).State = EntityState.Modified; db1.SaveChanges(); } } else { db1.Tbl_GestionDelCambio.Add(acccam); db1.SaveChanges(); } } } catch (Exception ex) { string mensaje = ex.ToString(); } return(GestionCambio); }