Esempio n. 1
0
        private bool modelIsValid(FileInputModel model, out string errorMsg)
        {
            errorMsg = string.Empty;
            string secretcode = Environment.GetEnvironmentVariable("secretcode");

            if (model.Code != secretcode)
            {
                errorMsg += "Invalid Code.\r\n";
            }

            if (string.IsNullOrWhiteSpace(model.ContestantNumber))
            {
                errorMsg += "Contestant Number is required.\r\n";
            }

            if (model.FileToUpload == null || model.FileToUpload.Length <= 0 || string.IsNullOrWhiteSpace(model.FileToUpload.FileName))
            {
                errorMsg += "Must Include a file to upload.\r\n";
            }
            else
            {
                if (!IsMediaFile(model.FileToUpload.FileName))
                {
                    errorMsg += "Invalid File Format.\r\n";
                }

                if (model.FileToUpload.Length > 1610612736)
                {
                    errorMsg += "File too big.\r\n";
                }
            }

            if (!string.IsNullOrWhiteSpace(errorMsg))
            {
                return(false);
            }

            return(true);
        }