示例#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();
        }