Esempio n. 1
0
        private void SaveCoverImageOnServer(ProductViewModel productViewModel, Product product)
        {
            var fileName = productViewModel.CoverImageBase.FileName;

            if (_fileFormatValidation.IsImageType(fileName))
            {
                SaveOnServer(productViewModel.CoverImageBase.FileName, Keys.CoverImageBase);
                product.ImageName = String.Concat(Keys.PathUploads + "/", productViewModel.CoverImageBase.FileName);
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Please upload a valid image file.");
            }
        }
        private void SaveCoverImageOnServer(BookViewModel bookViewModel, Book book)
        {
            var fileName = bookViewModel.CoverImageBase.FileName;

            if (_fileFormatValidation.IsImageType(fileName))
            {
                SaveOnServer(bookViewModel.CoverImageBase.FileName, Keys.CoverImageBase);
                book.CoverImageUrl = String.Concat(Keys.PathUploads + "/", bookViewModel.CoverImageBase.FileName);
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Please upload a valid image file.");
            }
        }