Example #1
0
 public DemandManager(IUnitOfWork uow, IDemandDAL demandDAL, IDemandTypeDAL demandTypeDAL, IOptions <FileUploadSettings> fileUploadSettings)
 {
     _uow = uow;
     _fileUploadSettings = fileUploadSettings.Value;
     _demandDAL          = demandDAL;
     _demandTypeDAL      = demandTypeDAL;
 }
Example #2
0
        public DataModelController(
            IOptions <FileUploadSettings> uploaderConfig,
            IOptions <MongoDbSettings> dbConfig)
        {
            var dbConfig1 = dbConfig.Value;

            _uploaderSettings = uploaderConfig.Value;

            _albumPlayedDatabase = new AlbumPlayedDatabase(dbConfig1.ConnectionString);
            _userDatabase        = new UserDatabase(dbConfig1.ConnectionString);
        }
Example #3
0
 public ProductManager(IUnitOfWork uow, IProductDAL productDAL, IProductDemandDAL productDemandDAL, IProductImageDAL productImageDAL, IBrandDAL brandDAL, IColorDAL colorDAL, ICategoryDAL categoryDAL, IDemandTypeDAL demandTypeDAL, IOptions <FileUploadSettings> fileUploadSettings, IProductColorDAL productColorDAL)
 {
     _uow                = uow;
     _productDAL         = productDAL;
     _productDemandDAL   = productDemandDAL;
     _productColorDAL    = productColorDAL;
     _productImageDAL    = productImageDAL;
     _brandDAL           = brandDAL;
     _colorDAL           = colorDAL;
     _categoryDAL        = categoryDAL;
     _demandTypeDAL      = demandTypeDAL;
     _fileUploadSettings = fileUploadSettings.Value;
 }
        public void ReturnFileUploadSettings()
        {
            var settings = new FileUploadSettings()
            {
                FileSizeLimitInMB    = 123,
                FileTypesAllowed     = "pizza|grape",
                FileTypesAllowedList = new List <string>()
                {
                    "pizza", "grape"
                }
            };
            IOptions <FileUploadSettings> settingOptions = Options.Create(settings);

            var sut    = new ValuesController(settingOptions);
            var result = sut.Get();

            var okResult = result as OkObjectResult;

            Assert.That(okResult.Value, Is.TypeOf <FileUploadSettings>());
        }
Example #5
0
 public ProductsController(IProductService ProductService,
                           IOptionsSnapshot <FileUploadSettings> fileUploadSettings)
 {
     this.ProductService     = ProductService;
     this.fileUploadSettings = fileUploadSettings.Value;
 }
Example #6
0
 public ProductController(IProductService productService, IOptions <FileUploadSettings> fileUploadSettings, IWebHostEnvironment webHostEnvironment)
 {
     _productService     = productService;
     _fileUploadSettings = fileUploadSettings.Value;
     _webHostEnvironment = webHostEnvironment;
 }
Example #7
0
        public static FileUploadResult UploadFile(HttpPostedFileBase content, FileUploadSettings fs, string customExtensions = "")
        {
            var fr = new FileUploadResult
            {
                IsSuccess       = false,
                NoFileSelected  = true,
                FileSizeInvalid = true,
                InvalidFileType = true,
                Message         = fs.Messages.Failed
            };
            var maxFileSizeBytes = (fs.MaxSize * 1024) * 1024;

            if (content != null)
            {
                fr.NoFileSelected = false;

                if (content.ContentLength > maxFileSizeBytes)
                {
                    fr.Message = fs.Messages.FileSizeInvalid;
                    return(fr);
                }
                else
                {
                    fr.FileSizeInvalid = false;

                    var extension = Path.GetExtension(content.FileName);

                    if (ValidateFileType(extension, fs.FileType, customExtensions))
                    {
                        fr.InvalidFileType = false;

                        var fileName     = string.Format("{0}{1}", Guid.NewGuid().ToString().Replace("-", "").ToLower(), extension);
                        var relativePath = fs.StoragePath + fileName;
                        var absolutePath = relativePath.MapPath();

                        try
                        {
                            content.SaveAs(absolutePath);

                            fr.IsSuccess = true;
                            fr.Result    = relativePath;
                            fr.Message   = fs.Messages.Success;
                        }
                        catch (Exception ex)
                        {
                            fr.Message = ExceptionHelper.GetExceptionMessage(ex);
                        }
                    }
                    else
                    {
                        fr.Message = fs.Messages.InvalidFileType;
                    }
                }
            }
            else
            {
                fr.Message = fs.Messages.NoFileSelected;
            }

            return(fr);
        }
Example #8
0
 public ValuesController(IOptions <FileUploadSettings> settings)
 {
     _settings = settings.Value;
 }
Example #9
0
 public DemandController(IDemandService demandService, IWebHostEnvironment webHostEnvironment, IOptions <FileUploadSettings> fileUploadSettings)
 {
     _demandService      = demandService;
     _webHostEnvironment = webHostEnvironment;
     _fileUploadSettings = fileUploadSettings.Value;
 }
Example #10
0
 public FileUploadController(IOptions <FileUploadSettings> uploaderConfig)
 {
     // Get the settings.
     _uploaderSettings = uploaderConfig.Value;
 }