Example #1
0
        public ActionResult AddProfileInfo(string Nombre, string Apellido, string Ubicacion, string Sexo, string Intereses, HttpPostedFileBase Avatar, PerfilModel model)
        {
            if (ModelState.IsValid)
            {
                var data = new byte[Avatar.ContentLength];
                Avatar.InputStream.Read(data, 0, Avatar.ContentLength);
                var path = ControllerContext.HttpContext.Server.MapPath("/Content/images/");
                var filename = Path.Combine(path, Path.GetFileName(Avatar.FileName));
                System.IO.File.WriteAllBytes(Path.Combine(path, filename), data);
                model.Nombre = Nombre;
                model.Apellido = Apellido;
                model.Intereses = Intereses;
                model.Ubicacion = Ubicacion;
                model.Sexo = Sexo;
                model.Avatar = Path.GetFileName(Avatar.FileName).ToString();
                model.AddPerfilInfo(model, User.Identity.Name);

                FormsAuthentication.SetAuthCookie(User.Identity.Name, false);
                return RedirectToAction("ViewInfo", "Profile");
            }
            return View();
        }
Example #2
0
 public void AddPerfilInfo(PerfilModel model, string name)
 {
     Guid idUs = ctx.aspnet_Users.Where(m => m.UserName == name).Select(m => m.UserId).ToArray()[0];
     int? idPer = (from per in ctx.perfils select per.id).Max();
     int id;
     if (idPer == null)
         id = 1;
     else
     {
         id = idPer.Value;
         id += 1;
     }
     perfil nuevo = new perfil()
     {
         id = id,
         nombre = model.Nombre,
         apellido = model.Apellido,
         avatar = model.Avatar,
         ubicacion = model.Ubicacion,
         intereses = model.Intereses,
         sexo = model.Sexo,
         estado = "Activo",
         idUs = idUs
     };
     ctx.perfils.InsertOnSubmit(nuevo);
     ctx.SubmitChanges();
 }
Example #3
0
 public ActionResult Index(PerfilModel model)
 {
     ViewBag.lista = model.ViewInfo(User.Identity.Name);
     return View();
 }