public ActionResult log() { perfil p = new perfil(); claseslinqDataContext f = new claseslinqDataContext(); Guid id = (from dt in f.aspnet_Users where dt.UserName == User.Identity.Name select dt.UserId).ToArray()[0]; p = (from c in f.perfils where c.UserId == id select c).ToArray()[0]; ViewBag.list = p; return View(); }
public ActionResult perfil(string nombre, string apellido, string pais, string intereses, string sexo, HttpPostedFileBase avatar) { var data = new byte[avatar.ContentLength]; avatar.InputStream.Read(data, 0, avatar.ContentLength); var path = ControllerContext.HttpContext.Server.MapPath("/imagenes"); var filename = Path.Combine(path, Path.GetFileName(avatar.FileName)); System.IO.File.WriteAllBytes(Path.Combine(path, filename), data); //FormsAuthentication.SetAuthCookie(User.Identity.Name, false); //return RedirectToAction("Index", "Home"); claseslinqDataContext regis = new claseslinqDataContext(); Guid idusuario = (from a in regis.aspnet_Users where a.UserName == User.Identity.Name select a.UserId).ToArray()[0]; perfil registrar = new perfil() { nombre=nombre,apellido=apellido,pais=pais,intereses=intereses, sexo=sexo, estado="activo", avatar=avatar.FileName ,UserId=idusuario }; regis.perfils.InsertOnSubmit(registrar); regis.SubmitChanges(); return View(); }