Esempio n. 1
0
        public ActionResult Index()
        {
            linq_sqlDataContext db = new linq_sqlDataContext();
            List<CategoriaView> cat = db.Categoria.Select(a => new CategoriaView { id = a.IdCategoria, nombre = a.Nombre }).ToList();
            List<Libros> descr = db.Info_Libro.Select(b => new Libros { id_pub = b.IdPublicacion, titulo = b.Titulo, descripcion = b.Descripcion, categoria = b.Nombre, megusta =Convert.ToInt32( b.MeGusta.ToString()), portada = b.Portada }).ToList();
            ViewBag.catego = cat;
            ViewBag.valor = descr;

            return View();
        }
Esempio n. 2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    linq_sqlDataContext db = new linq_sqlDataContext();
                    Usuario U = new Usuario { IdUsuario = System.Guid.NewGuid(), ApellidoPat = "", ApellidoMat = "", Nombre = "", Email = model.Email, Contrasena = model.Password, Avatar = "", Intereses = "", Karma = 0, NickName = "", Ubicacion = "" };

                    db.Usuario.InsertOnSubmit(U);
                    db.SubmitChanges();
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }