public async Task <IActionResult> Edit(int id, string projectName, IFormFile projectImage) { if (ModelState.IsValid) { try { var attachmentHandler = new AttachmentHandler(); var project = attachmentHandler.AttachToProject(projectImage); project.Name = projectName; project.Id = id; _context.Update(project); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Create([Bind("Name")] string projectName, IFormFile projectImage) { if (ModelState.IsValid) { var attachmentHandler = new AttachmentHandler(); var project = attachmentHandler.AttachToProject(projectImage); project.Name = projectName; _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }