コード例 #1
0
        public async Task <IActionResult> Create(CreateBookViewModel model)
        {
            string pdfPath   = null;
            string imagePath = null;

            _fileService.CreateDirectory();
            if (model.PdfFile != null)
            {
                pdfPath = await _fileService.AddFileAsync(model.PdfFile);
            }
            if (model.Image != null)
            {
                imagePath = await _fileService.AddFileAsync(model.Image);
            }
            await _bookService.CreateAsync(model, imagePath, pdfPath);

            return(RedirectToAction("GetBooks"));
        }
コード例 #2
0
        public async Task <IActionResult> Create(CreateCategoryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Categories = await _categoryService.GetAllInDictionaryAsync();

                return(View(model));
            }

            string filePath = null;

            if (model.File != null)
            {
                _fileService.CreateDirectory();
                filePath = await _fileService.AddFileAsync(model.File);
            }

            await _categoryService.CreateAsync(model, filePath);

            return(RedirectToAction("GetCategories"));
        }
コード例 #3
0
ファイル: Index.cshtml.cs プロジェクト: ooocode/WebDisk
 /// <summary>
 /// 上传文件
 /// </summary>
 /// <param name="upLoadFileInfo"></param>
 /// <returns></returns>
 public async Task <IActionResult> OnPostUploadFileAsync([FromBody] List <UpLoadFileInfo> upLoadFileInfos)
 {
     foreach (var upLoadFileInfo in upLoadFileInfos)
     {
         await fileService.AddFileAsync(new AddFileDto
         {
             DirectoryId = (Id ?? 0).ToString(),
             FileName    = upLoadFileInfo.FileName,
             Link        = upLoadFileInfo.Link,
             Size        = upLoadFileInfo.Size
         });
     }
     return(new OkResult());
 }