public IActionResult UploadFile(IList <IFormFile> files, int?parentFolder, [FromServices] SavePhotoCommand savePhotoCommand) { var list = new List <string>(); foreach (var file in files) { var model = new PhotoEditModel(); model.FileName = Path.GetFileName(file.FileName); model.Thumbnail = Path.GetFileName(file.FileName); model.ParentFolderId = parentFolder; model.File = file; var img = ImageFile.FromStream(file.OpenReadStream()); var latObject = (GPSLatitudeLongitude)img.Properties.FirstOrDefault(p => p.Name == "GPSLatitude"); var lonObject = (GPSLatitudeLongitude)img.Properties.FirstOrDefault(p => p.Name == "GPSLongitude"); if (latObject != null && lonObject != null) { model.Latitude = latObject.ToFloat(); model.Longitude = lonObject.ToFloat(); } list.AddRange(savePhotoCommand.Validate(model)); savePhotoCommand.Execute(model); } ViewBag.Messages = list; return(View()); }
public IActionResult UploadFile(IList <IFormFile> files, int?parentFolder, [FromServices] SavePhotoCommand savePhotoCommand) { var list = new List <string>(); foreach (var file in files) { var model = new PhotoEditModel(); model.FileName = Path.GetFileName(file.FileName); model.Thumbnail = Path.GetFileName(file.FileName); model.ParentFolderId = parentFolder; model.File = file; var img = ExifLibrary.ImageFile.FromStream(file.OpenReadStream()); foreach (var prop in img.Properties) { Debug.WriteLine(prop.Name + ": " + prop.Value); } list.AddRange(savePhotoCommand.Validate(model)); savePhotoCommand.Execute(model); } ViewBag.Messages = list; return(View()); }
// TODO List of Persons and list of items from DB public PhotoDetailViewModel(PhotoRepository photoRepository, IMessenger messenger) { _photoRepository = photoRepository; _messenger = messenger; SaveCommand = new SavePhotoCommand(photoRepository, this, messenger); PersonDetailCommand = new RelayCommand(PersonDetail); _messenger.Register <SelectedAlbumInAlbumListMessage>(OnLoad); _messenger.Register <NewPhotoMessage>(NewPhotoMessageRecieved); _messenger.Register <EditPhotoMessage>(EditPhotoMessageRecieved); _messenger.Register <ShowDetailPhotoMessage>(ShowDetailPhotoMessageReceived); _messenger.Register <SelectedPersonInPhotoViewMessage>(SelectedPerson); }
public PhotoDetailViewModel(PhotoRepository photoRepository, IMessenger messenger) { albumRepository = new AlbumRepository(); this.photoRepository = photoRepository; this.messenger = messenger; SavePhotoCommand = new SavePhotoCommand(photoRepository, this, messenger); DeletePhotoCommand = new RelayCommand(DeletePhoto); UpdatePhotoCommand = new RelayCommand(UpdatePhoto); this.messenger.Register <SelectedMessage>(SelectedPhoto); this.messenger.Register <NewMessage>(NewPhotoMessageReceived); this.messenger.Register <AlbumListUpdatedMessage>(UpdatedAlbum); }
public IActionResult UploadFile(IList <IFormFile> files, int?parentFolder, [FromServices] SavePhotoCommand savePhotoCommand) { var list = new List <string>(); foreach (var file in files) { var model = new PhotoEditModel(); model.FileName = Path.GetFileName(file.FileName); model.Thumbnail = Path.GetFileName(file.FileName); model.ParentFolderId = parentFolder; model.File = file; list.AddRange(savePhotoCommand.Validate(model)); savePhotoCommand.Execute(model); } ViewBag.Messages = list; return(View()); }
public IActionResult SavePhoto(/*int RecordId, string FileName, string Path,*/ [FromBody] SavePhotoCommand photo) { if (photo.File.Length > 0) { using (var fileStream = new FileStream(photo.FileName, FileMode.Create)) { photo.File.CopyTo(fileStream); //Path.Combine("wwwroot/xmphoto", photo.File.FileName); } } //string name = photo.FileName; //var img = photo.file; //Path.Combine("wwwroot/images", img.FileName); //if (img.Length > 0) //{ // using (var fileStream = new FileStream(img.FileName, FileMode.Create)) // { // img.CopyTo(fileStream); // Path.Combine("wwwroot/images",img.FileName); // } //} //var folderPath = System.IO.Path.Combine(hostingEnvironment.ContentRootPath, "xmphoto"); //if (!System.IO.Directory.Exists(folderPath)) //{ // System.IO.Directory.CreateDirectory(folderPath); //} //System.IO.File.WriteAllBytes((folderPath, FileName), Convert.FromBase64String(base64img)); //var imgByte = Convert.FromBase64String(photo.Base64); //var imgStream = new MemoryStream(imgByte); //imgStream.Position = 0; //File(imgByte, "img/jpg"); //Mediator.Send(new SavePhotoCommand { RecordId = RecordId , FileName = FileName, Path = Path }); // return Ok(Mediator.Send(photo)); return(Ok()); }