public ActionResult Upload(UploadFilePartialViewModel file) { UploadImageViewModel uploadImageViewModel = new UploadImageViewModel(); uploadImageViewModel.UploadFilePartialViewModel = file; IListenToUser user = (IListenToUser)this.HttpContext.User; try { //So that files which arent valid arent persisted, we use the ImageFileValidationHelper.. file = (UploadFilePartialViewModel)this.HandleTemporaryFile(file, new ImageFileValidationHelper()); } catch (InvalidFileTypeException e) { LOG.Info("Attempt to upload invalid image",e); } ListenTo.Shared.DO.Image image = null; try { image = ImageManager.HandleUploadedImage(file.Data, user.UserCredentials); uploadImageViewModel.ImageUploadSuccesful = true; uploadImageViewModel.Image = image; LOG.Info("User " + this.User.Identity.Name + " uploaded an image with id " + image.ID); } catch (ValidationException e) { e.AddToModelState(ViewData.ModelState); LOG.Info("Attempt to upload invalid image", e); } return View(uploadImageViewModel); }
public ActionResult Upload() { UploadImageViewModel uploadImageViewModel = new UploadImageViewModel(); uploadImageViewModel.UploadFilePartialViewModel = new UploadFilePartialViewModel(); return View(uploadImageViewModel); }