Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,Nombre,Telefono,IdPuesto,Email,Cedula,FechaContratacion,IdCuenta")] Empleado empleado)
        {
            if (ModelState.IsValid)
            {
                db.Empleados.Add(empleado);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(empleado));
        }
Exemplo n.º 2
0
        public ActionResult Registrar(RegistrarCliente r)
        {
            using (var db = new ServiciosClaroContext())
            {
                if (ModelState.IsValid)
                {
                    db.Cuentas.Add(new Cuenta()
                    {
                        Usuario = r.Usuario,
                        Clave   = r.Clave
                    });

                    db.SaveChanges();

                    var idcuenta = from c in db.Cuentas
                                   where c.Usuario == r.Usuario && c.Clave == r.Clave
                                   select c.Id;

                    int id = int.MinValue;

                    foreach (var item in idcuenta)
                    {
                        id = item;
                    }

                    db.Clientes.Add(new Cliente()
                    {
                        Nombre    = r.Nombre,
                        Direccion = r.Direccion,
                        Telefono  = r.Telefono,
                        Email     = r.Email,
                        IdCuenta  = id
                    });


                    db.RolCuentas.Add(new RolCuenta()
                    {
                        IdCuenta = id,
                        IdRol    = 3
                    });


                    db.SaveChanges();
                }
            }

            FormsAuthentication.SetAuthCookie(r.Usuario, false);

            return(RedirectToAction("Index", "Home"));
        }