public async Task <Photo> UploadPhoto(RealEstate realEstate, IFormFile file, string uploadsFolderPath) { var fileName = await photoStorage.StorePhoto(uploadsFolderPath, file); var photo = new Photo { FileName = fileName }; realEstate.Photos.Add(photo); await unitOfWork.CompleteAsync(); return(photo); }
public async Task <Photo> UploadPhoto(ApplicationUser user, IFormFile file, string uploadsFolderPath) { var fileName = await _photoStorage.StorePhoto(uploadsFolderPath, file); var photo = new Photo { FileName = fileName }; user.Avatar = photo; await _unitOfWork.CompleteAsync(); return(photo); }
public async Task <Photo> UploadPhoto(Vehicle vehicle, IFormFile file, string uploadsFolderPath) { var fileName = await photoStorage.StorePhoto(file, uploadsFolderPath); var photo = new Photo { FileName = fileName }; vehicle.Photos.Add(photo); await unitOfWork.CompleteAsync(); return(photo); }
public async Task <Photo> UploadPhoto(Vehicle vehicle, IFormFile file, string uploadsFolderPath) { var fileName = await photoStorage.StorePhoto(uploadsFolderPath, file); // System.Drawing -by self(new in .net Core)--option // save to database var photo = new Photo { FileName = fileName }; vehicle.Photos.Add(photo); await unitOfWork.Complete(); return(photo); }
public async Task <Photo> UploadAsync(Vehicule vehicule, IFormFile file, string uploadsFolderPath, bool addingThumbnail = true) { var fileInfo = await photoStorage.StorePhoto(uploadsFolderPath, file); var photo = new Photo { FileName = fileInfo.Name }; vehicule.Photos.Add(photo); await unitOfWork.CompleteAsync(); if (addingThumbnail) { var thumbnailsFolderPath = Path.Combine(uploadsFolderPath, "thumbnails"); Image thumbnail = ReducedImage(32, 32, fileInfo, thumbnailsFolderPath); } return(photo); }
public async Task <Photo> UploadPhoto(Vehicle vehicle, IFormFile file, string uploadsFolderPath) { var fileName = await photoStorage.StorePhoto(uploadsFolderPath, file); // System.Drawing to create thumbnail // Wasn't avail to Mosh but it is now // Update database var photo = new Photo { FileName = fileName }; vehicle.Photos.Add(photo); await unitOfWork.CompleteAsync(); // Could send notifications here return(photo); }
public async Task <IEnumerable <Photo> > UploadPhotos(Game game, IFormCollection files, string uploadsFolderPath) { var photos = new Collection <Photo>(); foreach (var file in files.Files) { var fileName = await photoStorage.StorePhoto(uploadsFolderPath, file); var photo = new Photo { FileName = fileName }; game.Photos.Add(photo); photos.Add(photo); } await unitOfWork.CompleteAsync(); return(photos); }
public Photo UploadPhoto(IFormFile file, IHostingEnvironment host) { try { var fileName = photoStorage.StorePhoto(file, host); /* * Create thumbnail image * A thumbnail image is a small version of an image. * You can create a thumbnail image by calling the GetThumbnailImage method of an Image object. * https://stackoverflow.com/questions/2808887/create-thumbnail-image */ var photo = new Photo { FileName = fileName }; return(photo); } catch (Exception e) { logger.LogError(e.Message); return(new Photo()); } }