public ActionResult Edit(ActividadVM model)
        {
            if (ModelState.IsValid)
            {
                var actividad = db.ACTIVIDAD.Find(model.ID_ACTIVIDAD);
                if (actividad == null)
                {
                    actividad = new ACTIVIDAD();
                    db.ACTIVIDAD.Add(actividad);
                }
                actividad.ESTADO            = model.ESTADO;
                actividad.FECHA_FIN         = model.FECHA_FIN;
                actividad.FECHA_INICIO      = model.FECHA_INICIO;
                actividad.ID_PROFESOR       = model.ID_PROFESOR;
                actividad.ID_ACTIVIDAD_TIPO = model.ID_ACTIVIDAD_TIPO;
                actividad.descripcion       = model.descripcion;


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    result = await UserManager.AddToRoleAsync(user.Id, model.RoleName);

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);


                    if (result.Succeeded)
                    {
                        var db = new dbClub();

                        var socio = new SOCIO
                        {
                            ID_SOCIO = user.Id,
                            APELLIDO = model.Apellido,
                            NOMBRE   = model.Nombre,
                            DNI      = model.DNI,
                        };
                        db.SOCIO.Add(socio);
                        db.SaveChanges();

                        // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                        // Send an email with this link
                        // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                        // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

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

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult Edit(LocacionVM model)
        {
            if (ModelState.IsValid)
            {
                var locacion = db.LOCACION.Find(model.ID_LOCACION);
                if (locacion == null)
                {
                    locacion = new LOCACION();
                    db.LOCACION.Add(locacion);
                }
                locacion.ID_TIPO_ACTIVIDAD = model.ID_TIPO_ACTIVIDAD;
                locacion.ESTADO            = model.ESTADO;
                locacion.DESCRIPCION       = model.DESCRIPCION;


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public ActionResult Edit(ProfesorVM model)
        {
            if (ModelState.IsValid)
            {
                var profesor = db.PROFESOR.Find(model.ID_PROFESOR);
                if (profesor == null)
                {
                    profesor = new PROFESOR();
                    db.PROFESOR.Add(profesor);
                }
                profesor.NOMBRE   = model.NOMBRE;
                profesor.APELLIDO = model.APELLIDO;
                profesor.DNI      = model.DNI;
                profesor.EMAIL    = model.EMAIL;
                profesor.ESTADO   = model.ESTADO;
                profesor.TELEFONO = model.TELEFONO;


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Exemplo n.º 5
0
 public ActionResult Create(ACTIVIDAD_TIPO model)
 {
     db.ACTIVIDAD_TIPO.Add(model);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }