コード例 #1
0
        public async Task <IActionResult> Create([Bind("TagId,Title")] Tag tag)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tag);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tag));
        }
コード例 #2
0
        public async Task <IActionResult> Create(CategoryVm category, string[] CategoryFolder)
        {
            if (ModelState.IsValid)
            {
                Category model = _mapper.Map <Category>(category);
                AddFolder(model, CategoryFolder);
                _context.Add(model);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ParentId"] = new SelectList(_context.Category, "CategoryId", "CategoryId", category.ParentId);
            return(View(category));
        }
コード例 #3
0
        public async Task <IActionResult> Create(DocumentVm document, string[] DocumentFolder, IFormFile File)
        {
            if (ModelState.IsValid)
            {
                Document model = _mapper.Map <Document>(document);
                AddFile(model, File);
                AddFolder(model, DocumentFolder);
                _context.Add(model);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(document));
        }
コード例 #4
0
        public async Task <IActionResult> Create(FolderVm folder, string[] CategoryFolder, string[] TagFolder, List <IFormFile> Files)
        {
            if (ModelState.IsValid)
            {
                Folder model = _mapper.Map <Folder>(folder);
                AddCategories(model, CategoryFolder);
                AddTags(model, TagFolder);
                AddFiles(model, Files);
                _context.Add(model);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ParentId"] = new SelectList(_context.Folder, "FolderId", "FolderId", folder.ParentId);
            return(View(folder));
        }