Esempio n. 1
0
        public async Task <IActionResult> SourceFileLoad(SourceFileStub SourceFileStub)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    SourceFile model  = new SourceFile();
                    FileStore  fmodel = new FileStore();

                    model.SourceType = SourceFileStub.SourceType;

                    using (var memoryStream = new MemoryStream())
                    {
                        await SourceFileStub.File.CopyToAsync(memoryStream);

                        fmodel.File    = memoryStream.ToArray();
                        model.Length   = SourceFileStub.File.Length;
                        model.FileName = SourceFileStub.File.FileName;
                    }

                    _sourceFile.Add(model);
                    _sourceFile.Save();
                    fmodel.id = model.id;
                    _fileStore.Add(fmodel);
                    _fileStore.Save();

                    TempData["Error"] = "This file is Added FileSores";
                }
                catch (Exception ex)
                {
                    TempData["Error"] = ex.Message.ToString();
                }
            }



            return(RedirectToAction("SourceFileLoad"));
        }