Esempio n. 1
0
        public ActionResult Editar(TablaaViewModel model)
        {
            try
            {
                //validacion
                if (ModelState.IsValid)
                {
                    using (TablaEntities1 db = new TablaEntities1())
                    {
                        var oTabla = db.tabla.Find(model.Id);
                        oTabla.correo = model.correo;
                        oTabla.nombre = model.nombre;
                        //oTabla.fecha_nacimiento = model.fecha_nacimiento;

                        db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    return(Redirect("~/tabla/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 2
0
        public ActionResult Nuevo(TablaaViewModel model)
        {
            try
            {
                //validacion
                if (ModelState.IsValid)
                {
                    using (TablaEntities1 db = new TablaEntities1())
                    {
                        var oTabla = new tabla();
                        oTabla.correo = model.correo;
                        oTabla.sueldo = model.sueldo;
                        oTabla.nombre = model.nombre;
                        //oTabla.fecha_nacimiento = model.fecha_nacimiento;

                        db.tabla.Add(oTabla);
                        db.SaveChanges();
                    }
                    return(Redirect("~/tabla/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }