public PhotosController(IPhotoService photoService, IMapper mapper, IPhotoUpload photoUpload, ICountService countService) { _photoService = photoService; _mapper = mapper; _photoUpload = photoUpload; _countService = countService; }
public bool SaveImage(IPhotoUpload model) { try { string imagesPath = model.ServerPath + model.StudentId; Directory.CreateDirectory(imagesPath); string image = imagesPath + "\\" + model.FileName; if (File.Exists(image) && !model.ReplaceExisting) { model.FileNameExists = true; _log.LogError(new Exception("File Already Exists: " + model.StudentId + " - " + model.FileName), "Error Saving Image to directory"); return false; } using (FileStream fileToSave = new FileStream(image, FileMode.Create)) { model.ImageData.CopyTo(fileToSave); } if (!File.Exists(image)) { throw new Exception("Failed To Save File"); } return true; } catch (Exception e) { _log.LogError(e,"Error Saving Image to directory"); return false; } }
public ChannelsController(IChannelService channelService, IMapper mapper, IPhotoUpload photoUpload, ICountService countService) { _channelService = channelService; _mapper = mapper; _photoUpload = photoUpload; _countService = countService; }
public void DeleteImage(IPhotoUpload model) { try { string imagesPath = model.ServerPath + model.StudentId; string image = imagesPath + "\\" + model.FileName; File.Delete(image); } catch (Exception e) { _log.LogError(e, "Error Deleting Image from directory"); } }
private RepositoryManagment() { _photosEntity = new eventerEntities(); _photoUploader = new S3Client(); }