public ActionResult Create(Person person) { if (ModelState.IsValid) { db.PersonSet.Add(person); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.BoatId = new SelectList(db.BoatSet, "Id", "Name"); return View(person); }
public ActionResult Edit(Person person, UploadImageModel viewModel) { if (viewModel.UploadImage != null && viewModel.UploadImage.ContentLength > 0) { byte[] buffer = new byte[viewModel.UploadImage.ContentLength]; viewModel.UploadImage.InputStream.Read(buffer, 0, viewModel.UploadImage.ContentLength); person.Image = buffer; } if (ModelState.IsValid) { db.Entry(person).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("EditTeam", new { id=person.BoatId }); } ViewBag.BoatId = new SelectList(db.BoatSet, "Id", "Name", person.BoatId); return View(person); }