Exemplo n.º 1
0
        public IResult Add(CarImage carImage, IFormFile formFile)
        {
            carImage.Date      = DateTime.Now;
            carImage.ImagePath = FileHelper.AddFile(formFile);

            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
Exemplo n.º 2
0
        public IResult Add(CarImage carImage, IFormFile file)
        {
            IResult result = BusinessRules.Run(CheckCarImageLimit(carImage.CarId));

            if (result != null)
            {
                return(result);
            }
            carImage.ImageDate = DateTime.Now;
            carImage.ImagePath = FileHelper.AddFile(file);

            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.CarImageAdded));
        }
Exemplo n.º 3
0
        public IResult Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckImageLimitExceeded(carImage.CarId));

            if (result != null)
            {
                return(result);
            }

            carImage.ImagePath = FileHelper.AddFile(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
Exemplo n.º 4
0
        public IResult Add(IFormFile objectFile, string filePath, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckIfImageLimit(carImage.CarId), checkid(carImage.CarId));

            if (result != null)
            {
                return(result);
            }
            else
            {
                carImage.ImagePath = FileHelper.AddFile(objectFile, filePath);
                carImage.Date      = DateTime.Now;
                _carImageDal.Add(carImage);
                return(new SuccessResult(Messages.CarImageAdded));
            }
        }
Exemplo n.º 5
0
        public void ParseFilePaths()
        {
            List <FileItem> fileEmptyItems = FileHelper.GetParseFilePaths(String.Empty);

            Assert.AreEqual(0, fileEmptyItems.Count);

            List <string> filePaths = new List <string>();

            filePaths.Add(@"1*C:\Windows\System32\AERTAC64.dll");
            filePaths.Add(@"2*C:\Windows\System32\3082\vsjitdebuggerui.dll");
            filePaths.Add(@"3*C:\Windows\System32\DAX2\DAX2.sdf");
            string allPath = String.Empty;

            foreach (string filePath in filePaths)
            {
                allPath += filePath + "|";
            }

            allPath = allPath.Remove(allPath.Length - 1, 1);
            List <FileItem> fileItems = FileHelper.GetParseFilePaths(allPath);

            Assert.AreEqual(3, fileItems.Count);
            Assert.AreEqual("AERTAC64.dll", fileItems[0].FileName);
            Assert.AreEqual("vsjitdebuggerui.dll", fileItems[1].FileName);
            Assert.AreEqual("DAX2.sdf", fileItems[2].FileName);

            Assert.AreEqual(String.Empty, FileHelper.GetMergedFilePaths(new List <FileItem>()));
            Assert.AreEqual(allPath, FileHelper.GetMergedFilePaths(fileItems));

            FileHelper.AddFile(fileItems, @"C:\Windows\System32\DAX2\DRTAIODAT2.DAT", 3);
            Assert.AreEqual(3, fileItems.Count);
            Assert.AreEqual("DRTAIODAT2.DAT", fileItems[0].FileName);
            Assert.AreEqual("AERTAC64.dll", fileItems[1].FileName);
            Assert.AreEqual("vsjitdebuggerui.dll", fileItems[2].FileName);

            string file = @"C:\Windows\System32\AERTAC64.dll";

            FileHelper.AddFile(fileItems, file, 3);
            Assert.AreEqual(3, fileItems.Count);
            Assert.AreEqual("AERTAC64.dll", fileItems[0].FileName);
            Assert.AreEqual("DRTAIODAT2.DAT", fileItems[1].FileName);
            Assert.AreEqual("vsjitdebuggerui.dll", fileItems[2].FileName);

            Assert.AreEqual(file, FileHelper.GetFirstFileItemPath(FileHelper.GetMergedFilePaths(fileItems)));
        }
Exemplo n.º 6
0
        public IResult Add(CarImage carImage, IFormFile formFile)
        {
            //var result = CheckImageLimit(carImage.CarId);
            //if (!result.Success)
            //{
            //    return result;
            //}

            var result = BusinessRules.Run(CheckImageLimit(carImage.CarId));

            if (result != null)
            {
                return(result);
            }

            if (formFile != null)
            {
                var filePath = FileHelper.AddFile(formFile);
                if (filePath.Success)
                {
                    _imageDal.Add(new CarImage
                    {
                        CarId     = carImage.CarId,
                        ImagePath = filePath.Data
                    });
                    return(new SuccessResult());
                }
            }
            else
            {
                _imageDal.Add(new CarImage
                {
                    CarId     = carImage.CarId,
                    ImagePath = SetDefaultImage()
                });
                return(new SuccessResult());
            }
            return(new ErrorResult());
        }
Exemplo n.º 7
0
 private void OpenRecentFile(FileItem entity)
 {
     FileHelper.AddFile(FileItems, entity.FilePath, settingService.GetMaxRecentFilePaths());
     eventAggregator.GetEvent <OpenFileEvent>().Publish(entity.FilePath);
 }