Esempio n. 1
0
        public void TestSave()
        {
            Guid fileReferenceId;

            var filePath = FileSystem.GetAbsolutePath(@"Test\Data\Photos\ProfilePhoto.jpg", RuntimeEnvironment.GetSourceFolder());

            using (var stream = File.Open(filePath, FileMode.Open))
            {
                fileReferenceId = _employerLogosCommand.SaveLogo(new StreamFileContents(stream), filePath).Id;
            }

            var fileReference = _filesQuery.GetFileReference(fileReferenceId);

            Assert.AreEqual(Path.GetFileName(filePath), fileReference.FileName);
            Assert.AreEqual("image/jpeg", fileReference.MediaType);
            Assert.AreEqual(".jpg", fileReference.FileData.FileExtension);
            Assert.AreEqual(FileType.CompanyLogo, fileReference.FileData.FileType);
        }
Esempio n. 2
0
        private void CreateLogo(JobAdModel jobAdModel, HttpPostedFileBase logo, Guid?logoId)
        {
            jobAdModel.Logo = new LogoModel();
            if (logo == null && logoId == null)
            {
                return;
            }

            if (logo == null)
            {
                // File already uploaded.

                jobAdModel.Logo.FileReferenceId = logoId;
                return;
            }

            // Uploading a new file.

            var fileName      = Path.GetFileName(logo.FileName);
            var fileReference = _employerLogosCommand.SaveLogo(new HttpPostedFileContents(logo), fileName);

            jobAdModel.Logo.FileReferenceId = fileReference.Id;
        }