public ActionResult Edit([Bind(Exclude = "UserPhoto")] DisplayInfosModel model) { using (MyAppContext context = new MyAppContext()) { UserRepository repo = new UserRepository(context); User user = repo.getUser(HttpContext.User.Identity.Name); user.firstName = model.firstName; user.lastName = model.lastName; user.email = model.email; //user.nickName = model.nickName; HttpPostedFileBase poImgFile = Request.Files["UserPhoto"]; if (poImgFile.ContentLength != 0) { byte[] imageData = null; using (var binary = new BinaryReader(poImgFile.InputStream)) { imageData = binary.ReadBytes(poImgFile.ContentLength); } user.UserPhoto = imageData; context.SaveChanges(); } return(RedirectToAction("Index", "Profil")); } }
public ActionResult Edit() { using (MyAppContext context = new MyAppContext()) { UserRepository repo = new UserRepository(context); User user = repo.getUser(HttpContext.User.Identity.Name); DisplayInfosModel model = new DisplayInfosModel() { email = user.email, firstName = user.firstName, lastName = user.lastName, //nickName = user.nickName }; return(View(model)); } }
public ActionResult OtherProfil() { String nickName = Request.QueryString["nickName"]; using (MyAppContext context = new MyAppContext()) { UserRepository repo = new UserRepository(context); User user = repo.getUser(nickName); DisplayInfosModel model = new DisplayInfosModel() { email = user.email, firstName = user.firstName, lastName = user.lastName, nickName = user.nickName, UserPhoto = user.UserPhoto }; return(View(model)); } }
public ActionResult Index() { using (MyAppContext context = new MyAppContext()) { UserRepository repo = new UserRepository(context); List <User> users = repo.getAll(); List <DisplayInfosModel> models = new List <DisplayInfosModel>(); foreach (User u in users) { DisplayInfosModel model = new DisplayInfosModel() { email = u.email, firstName = u.firstName, lastName = u.lastName, nickName = u.nickName }; models.Add(model); } return(View(models)); } }