public static PhotoEntity ToBllPhoto(this LoadPhotoModel photo) { return(new PhotoEntity() { Image = photo.Image, Description = photo.Description, LoadDate = DateTime.Now.Date }); }
public ActionResult LoadPhoto(LoadPhotoModel photo, HttpPostedFileBase[] files) { if (ModelState.IsValid && files != null) { foreach (var item in files) { byte[] imageData = null; using (var binaryReader = new BinaryReader(item.InputStream)) { imageData = binaryReader.ReadBytes(item.ContentLength); } photo.Image = imageData; userService.LoadPhoto(photo.ToBllPhoto(), User.Identity.Name); } return(Redirect("/Album/Index")); } return(View(photo)); }