Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }