예제 #1
0
 public PhotosController(IPhotoService photoService, IMapper mapper, IPhotoUpload photoUpload, ICountService countService)
 {
     _photoService = photoService;
     _mapper       = mapper;
     _photoUpload  = photoUpload;
     _countService = countService;
 }
예제 #2
0
        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;
 }
예제 #4
0
 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");
     }
 }
예제 #5
0
 private RepositoryManagment()
 {
     _photosEntity  = new eventerEntities();
     _photoUploader = new S3Client();
 }