Ejemplo n.º 1
0
        public IActionResult UploadPhoto(IFormFile file, [FromQuery] int?productId, [FromQuery] int?orderBy)
        {
            var fileName = _fileManager.Upload(file);
            var publicId = _cloudinaryService.Store(fileName);

            _fileManager.Delete(fileName);

            if (productId != null)
            {
                ProductPhoto productPhoto = new ProductPhoto()
                {
                    AddedDate = DateTime.Now,
                    Img       = _cloudinaryService.BuildUrl(publicId),
                    FileName  = publicId,
                    ProductId = (int)productId,
                    OrderBy   = (int)orderBy
                };
                _productService.AddPhoto(productPhoto);
            }

            return(Ok(new {
                fileName = publicId,
                src = _cloudinaryService.BuildUrl(publicId)
            }));
        }
Ejemplo n.º 2
0
        public IActionResult Create(FileDTO file)
        {
            string path = FileManager.IFormSave(file.File, "temp");
            string id   = _cloudinary.Store(path);

            File newFile = new File
            {
                FilePath = id,
                FileName = file.File.Name
            };

            _fileService.Create(newFile);
            object data = new
            {
                senderEmail = file.From,
                fileCount   = "1",
                fileSize    = file.File.Length / 1000000,
                date        = DateTime.UtcNow.ToString("dd-MM-yyyy"),
                message     = file.Message
            };

            _emailService.Send(file.To, "SenderMan", "d-489e8c077adb4797be48273d349760cf", data);

            return(RedirectToAction("index"));
        }
        public IActionResult Upload(IFormFile file)
        {
            var filename = _fileManager.Upload(file);
            var publicId = _cloudinaryService.Store(filename);

            _fileManager.Delete(filename);

            return(Ok(publicId));
        }
        public IActionResult ProfileImgUpload(IFormFile file)
        {
            var filename = _fileManager.Upload(file);

            var publicId = _cloudinaryService.Store(filename);

            _fileManager.Delete(filename);
            if (_user.ProfileImg != null)
            {
                _cloudinaryService.Delete(_user.ProfileImg);
            }
            _accountDetailRepository.ProfileImgUpload(_user.Id, publicId);



            return(Ok(new
            {
                filename = publicId,
                src = _cloudinaryService.BuildUrl(publicId)
            }));
        }
Ejemplo n.º 5
0
        public IActionResult Upload(IFormFile file, int?id)
        {
            var filename = _fileManager.Upload(file);
            var publicId = _cloudinaryService.Store(filename);

            _fileManager.Delete(filename);


            if (id != null)
            {
                var service = _serviceRepository.GetServiceById(id);
                service.Image = publicId;
                _context.SaveChanges();
            }


            return(Ok(new {
                filename = publicId,
                src = _cloudinaryService.BuildUrl(publicId)
            }));
        }
Ejemplo n.º 6
0
        public IActionResult Upload(IFormFile file, int?brandId)
        {
            var filename = _fileManager.Upload(file);
            var publicId = _cloudinaryService.Store(filename);

            _fileManager.Delete(filename);

            if (brandId != null)
            {
                ProductBrand brandPhoto = new ProductBrand
                {
                    Image = publicId,
                };
                _departmentRepository.AddPhoto(brandPhoto);
            }

            return(Ok(new
            {
                filename = publicId,
                src = _cloudinaryService.BuildUrl(publicId)
            }));
        }
Ejemplo n.º 7
0
        public IActionResult Upload(IFormFile file, int?newsId, int?orderBy)
        {
            var filename = _fileManager.Upload(file);
            var publicId = _cloudinaryService.Store(filename);

            _fileManager.Delete(filename);
            if (newsId != null)
            {
                NewsPhoto newsPhoto = new NewsPhoto
                {
                    ModifiedBy = _admin.Fullname,
                    CreatedAt  = DateTime.Now,
                    Image      = publicId,
                    NewsId     = (int)newsId,
                    OrderBy    = (int)orderBy
                };
                _newsService.AddPhoto(newsPhoto);
            }
            return(Ok(new
            {
                filename = publicId,
                src = _cloudinaryService.BuildUrl(publicId)
            }));
        }
Ejemplo n.º 8
0
        public IActionResult Upload(IFormFile file, int?sliderId)
        {
            var filename = _fileManager.Upload(file);
            var publicId = _cloudinaryService.Store(filename);

            _fileManager.Delete(filename);

            if (sliderId != null)
            {
                SliderItem slidePhoto = new SliderItem
                {
                    //AddedBy = _admin.Fullname,
                    //AddedDate = DateTime.Now,
                    Image = publicId,
                };
                //_sliderRepository.AddPhoto(slidePhoto);
            }

            return(Ok(new
            {
                filename = publicId,
                src = _cloudinaryService.BuildUrl(publicId)
            }));
        }