Beispiel #1
0
        public ActionResult Create([Bind(Include = "id_departamento,nombre,descripcion")] departamentos departamentos)
        {
            if (ModelState.IsValid)
            {
                db.departamentos.Add(departamentos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(departamentos));
        }
        public JsonResult GuardarPersonas(FormCollection f)
        {
            string activo = f["activo"];

            Thread.CurrentThread.CurrentCulture = new CultureInfo("es-CR");
            TimeZoneInfo setTimeZoneInfo;
            DateTime     currentDateTime;

            //Set the time zone information to US Mountain Standard Time
            setTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Central America Standard Time");

            //Get date and time in US Mountain Standard Time
            currentDateTime = TimeZoneInfo.ConvertTime(DateTime.Now, setTimeZoneInfo);

            //Print out the date and time
            DateTime   hora      = currentDateTime;
            int        x         = 1;
            eResultado Resultado = new eResultado();
            int        id        = Convert.ToInt32(f["departamento"]);

            try
            {
                using (DB_A1E868_ingresoCTPEntities bd = new DB_A1E868_ingresoCTPEntities())

                {
                    //NUEVO
                    Visitantes Personas = new Visitantes();
                    {
                        Personas.cedula          = f["cedula"];
                        Personas.placa           = f["placa"];
                        Personas.nombre          = f["nombre"];
                        Personas.apellidos       = f["apellidos"];
                        Personas.id_departamento = id;
                        Personas.fecha_ingreso   = hora;
                    }
                    bd.Visitantes.Add(Personas);
                    //if (activo == "0")
                    //{
                    //    TSE personasActivas = new TSE();
                    //    {
                    //        personasActivas.Nombre = f["nombre"];
                    //        personasActivas.Apellido1 = f["apellidos"];
                    //        personasActivas.Cedula = f["cedula"];
                    //    }
                    //    bd.TSE.Add(personasActivas);
                    //}

                    bd.SaveChanges();
                }

                x = 1;
                Resultado.Estado = true;
            }
            catch (Exception ex)
            {
                x = 2;
                Resultado.Estado      = false;
                Resultado.TipoMensaje = 3;
            }
            return(Json(x, JsonRequestBehavior.AllowGet));
        }