public async Task <IActionResult> Create([Bind("RoastingLevelId,RoastingLevelName,Description,File,createdAt")] RoastingLevel roastingLevel, IFormFile File) { if (File != null) { using (var stream = new MemoryStream()) { await File.CopyToAsync(stream); roastingLevel.File = stream.ToArray(); } } if (ModelState.IsValid) { _context.Add(roastingLevel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(roastingLevel)); }
public async Task <IActionResult> Edit(string id, [Bind("RoastingLevelId,RoastingLevelName,Description,File,createdAt")] RoastingLevel roastingLevel, IFormFile File) { if (id != roastingLevel.RoastingLevelId) { return(NotFound()); } if (File != null) { using (var stream = new MemoryStream()) { await File.CopyToAsync(stream); roastingLevel.File = stream.ToArray(); } } if (ModelState.IsValid) { try { _context.Update(roastingLevel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoastingLevelExists(roastingLevel.RoastingLevelId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(roastingLevel)); }
// GET: RoastingLevel/Create public IActionResult Create() { RoastingLevel roastLevel = new RoastingLevel(); return(View(roastLevel)); }