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());
        }
        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());
        }
Exemple #3
0
        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());
        }