public async Task <IActionResult> Create([Bind("ID,MainRace,Name,Description,Features,Spellcasting,Source")] Subraces subraces) { if (ModelState.IsValid) { _context.Add(subraces); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(subraces)); }
public async Task <IActionResult> Create([Bind("ID,Name,Summary,Permission,Path,Category")] Sources sources) { if (ModelState.IsValid) { _context.Add(sources); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sources)); }
public async Task <IActionResult> Create([Bind("ID,Name,Level,CastingTime,Range,Components,Duration,School,Description,Source")] Spells spells) { if (ModelState.IsValid) { _context.Add(spells); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Source"] = new SelectList(_context.Sources, "ID", "ID", spells.Source); return(View(spells)); }
public async Task <IActionResult> Create([Bind("ID,Name,Summary,Permission,Path,Category")] Sources sources, IFormFile BookPath) { //add books String fullPath = ""; bool bookExists = false; if (BookPath == null) { sources.Path = null; } else { if (BookPath.ContentType == "text/pdf" || bookExists == false) { Guid g; g = Guid.NewGuid(); String type = Path.GetExtension(BookPath.FileName).ToLower(); String name = g.ToString() + type; fullPath = Path.Combine(_path.WebRootPath, "books", name); sources.Path = name; bookExists = true; } else { sources.Path = ""; } } if (ModelState.IsValid) { _context.Add(sources); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sources)); }