public string AddInstitucion(string desc, string nom, string pais) { V_INSTITUCION inst = new V_INSTITUCION(); inst.X_SISTEMA = true; inst.CAT_INSTITUCION = -1; inst.FULL_NAME = nom; inst.DESCRIPCION = desc; string nompais = pais.ToUpper(); V_PAISES ipais = BDRegistro.V_PAISES.Where(x => String.Equals(x.NOMBRE, nompais)).FirstOrDefault(); inst.COUNTRY = (ipais == null) ? null : ipais.ISO; inst.CREADO = DateTime.Now; inst.PAIS = ipais; try { BDRegistro.V_INSTITUCION.Add(inst); BDRegistro.SaveChanges(); return(ViewResources.Resources.insercionCorrecta); } catch { return(ViewResources.Resources.insercionMala); } }
public ActionResult EditOET(INFOVISITA infov, FormCollection collection) { int mensaje = 0; if (ModelState.IsValid) { /*if (infov.PERSONA.GENERO == ViewResources.Resources.oet_fem) * { * infov.PERSONA.GENERO = '1'.ToString(); * * } * else * { * infov.PERSONA.GENERO = '0'.ToString(); * }*/ string genero = collection["PERSONA.GENERO"]; if (genero == ViewResources.Resources.oet_fem) // si es femenino { infov.PERSONA.GENERO = 'F'.ToString(); } else { infov.PERSONA.GENERO = 'M'.ToString(); //es masculino } string nominst = (string)collection["PERSONA.INSTITUCIONI.FULL_NAME"]; V_INSTITUCION inst = BDRegistro.V_INSTITUCION.Where(x => String.Equals(x.FULL_NAME, nominst)).FirstOrDefault(); infov.PERSONA.INSTITUCION = (inst == null) ? (int?)null : inst.CAT_INSTITUCION; infov.PERSONA.INSTITUCIONI = inst; string nompais = (string)collection["PERSONA.PAISI.NOMBRE"].ToUpper();; V_PAISES pais = BDRegistro.V_PAISES.Where(x => String.Equals(x.NOMBRE, nompais)).FirstOrDefault(); infov.PERSONA.PAIS = (pais == null) ? null : pais.ISO; infov.PERSONA.PAISI = pais; string gentpais = (string)collection["PERSONA.NACIONALIDADI.GENTILICIO"].ToUpper(); V_PAISES nacion = BDRegistro.V_PAISES.Where(x => String.Equals(x.GENTILICIO, gentpais)).FirstOrDefault(); infov.PERSONA.NACIONALIDAD = (nacion == null) ? null : nacion.ISO; infov.PERSONA.NACIONALIDADI = nacion; BDRegistro.Entry(infov).State = EntityState.Modified; BDRegistro.Entry(infov.PERSONA).State = EntityState.Modified; BDRegistro.SaveChanges(); mensaje = 1; return(RedirectToAction("DetailsOET", new { idR = infov.ID_RESERVACION, cedula = infov.CEDULA, mensaje })); } mensaje = 0; return(RedirectToAction("DetailsOET", new { idR = infov.ID_RESERVACION, cedula = infov.CEDULA, mensaje })); }
public ActionResult CreateOET(String idRes, [Bind()] Models.INFOVISITA form, FormCollection collection, string dietas, string genero, bool checkPollo = false, bool checkCarne = false, bool checkCerdo = false, bool checkPescado = false) { int mensaje = -1; if (idRes == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.idRes = idRes; var reservacion = BDRegistro.V_RESERVACION.Find(idRes); if (reservacion == null || !reservacion.ANFITRIONA.Equals("01")) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); // 404 } form.CARNE = checkCarne; //checkboxes form.POLLO = checkPollo; form.CERDO = checkCerdo; form.PESCADO = checkPescado; if (form.PERSONA.GENERO == ViewResources.Resources.oet_fem)//si es femenino { form.PERSONA.GENERO = 'F'.ToString(); } else { form.PERSONA.GENERO = 'M'.ToString(); //masculino } form.ID_RESERVACION = idRes; form.CEDULA = form.PERSONA.CEDULA; form.ESTADO = "A"; if (ModelState.IsValid) { var db = BDRegistro; string nominst = (string)collection["PERSONA.INSTITUCIONI.FULL_NAME"]; V_INSTITUCION inst = BDRegistro.V_INSTITUCION.Where(x => String.Equals(x.FULL_NAME, nominst)).FirstOrDefault(); form.PERSONA.INSTITUCION = (inst == null) ? (int?)null : inst.CAT_INSTITUCION; form.PERSONA.INSTITUCIONI = inst; string nompais = (string)collection["PERSONA.PAISI.NOMBRE"].ToUpper();; V_PAISES pais = BDRegistro.V_PAISES.Where(x => String.Equals(x.NOMBRE, nompais)).FirstOrDefault(); form.PERSONA.PAIS = (pais == null) ? null : pais.ISO; form.PERSONA.PAISI = pais; string gentpais = (string)collection["PERSONA.NACIONALIDADI.GENTILICIO"].ToUpper(); V_PAISES nacion = BDRegistro.V_PAISES.Where(x => String.Equals(x.GENTILICIO, gentpais)).FirstOrDefault(); form.PERSONA.NACIONALIDAD = (nacion == null) ? null : nacion.ISO; form.PERSONA.NACIONALIDADI = nacion; string insti = (string)collection["PERSONA.INSTITUCIONI.FULL_NAME"].ToUpper(); V_INSTITUCION institucion = BDRegistro.V_INSTITUCION.Where(x => String.Equals(x.FULL_NAME, gentpais)).FirstOrDefault(); if (institucion != null) { form.PERSONA.INSTITUCION = institucion.CAT_INSTITUCION; } form.PERSONA.INSTITUCIONI = institucion; form.CEDULA = form.PERSONA.CEDULA; var cedulaP = BDRegistro.PERSONA.Find(form.PERSONA.CEDULA); db.INFOVISITA.Add(form); if (cedulaP != null) { db.Entry(cedulaP).State = EntityState.Detached; db.PERSONA.Attach(form.PERSONA); db.Entry(form.PERSONA).State = EntityState.Modified; } try { db.SaveChanges(); //se guarda la información } catch (Exception e) { mensaje = 0; return(RedirectToAction("CreateOET", new { idRes, mensaje })); } // return RedirectToAction("Index"); } mensaje = 1; return(RedirectToAction("CreateOET", new { idRes, mensaje })); }