private void GetPictureForUser(User user, HttpPostedFileBase Picture) { if (Picture != null) { user.FileName = Picture.FileName; user.ContentType = Picture.ContentType; using (var reader = new BinaryReader(Picture.InputStream)) { //picture.Picture = reader.ReadBytes(Pictures[i].ContentLength); user.Photo = PictureController.GetCroppedImage(reader.ReadBytes(Picture.ContentLength), PictureController.GetFormatImage(Picture.ContentType)); } } }
public ActionResult Edit(User user, string[] Language, HttpPostedFileBase Picture) { if (this.ModelState.IsValid) { GetPictureForUser(user, Picture); bool updated = manager.UpdateUser(user, Language); if (updated) { Storage.currentUser = null; return RedirectToAction("Index"); } else { FillDropDownListCountriesAndLanguages(user.id); ModelState.AddModelError("EmailIsHave", "This user is already registered."); } } else ModelState.AddModelError("ValidIsFailed", "Fail."); return View(); }