Exemplo n.º 1
0
        //
        // GET: /AboutDetail/Create
        public ActionResult Create(Guid id)
        {
            //var aboutperson = db.AboutPerson.Include(a => a.person);
            var aboutperson = db.AboutPerson.Include(m => m.person).Where(p => p.PersonId == id).FirstOrDefault();
              //  var per = Session["Person"] as Person;

            if (aboutperson == null)
            {
                aboutperson = new AboutPerson();
                aboutperson.Id = Guid.NewGuid();
                aboutperson.PersonId = id;
            }

            return View(aboutperson);
        }
Exemplo n.º 2
0
        public ActionResult Create(AboutPerson aboutperson)
        {
            if (ModelState.IsValid)
            {
                aboutperson.person = db.People.Where(p => p.ID == aboutperson.PersonId).FirstOrDefault();
                if (aboutperson.person != null)
                {
                    aboutperson.Id = Guid.NewGuid();
                    db.AboutPerson.Add(aboutperson);
                    db.SaveChanges();
                }
                else
                {
                    var aboutperso = new AboutPerson();
                    aboutperso.AboutDetail = aboutperson.AboutDetail;
                    aboutperson = db.AboutPerson.Include(p => p.person).Where(m => m.PersonId == aboutperson.PersonId).FirstOrDefault();
                    aboutperson.AboutDetail = aboutperso.AboutDetail;
                    db.Entry(aboutperson).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return View(aboutperson);
            }

            ViewBag.PersonId = new SelectList(db.People, "ID", "Title", aboutperson.PersonId);
            return View(aboutperson);
        }
Exemplo n.º 3
0
 public ActionResult Edit(AboutPerson aboutperson)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aboutperson).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.PersonId = new SelectList(db.People, "ID", "Title", aboutperson.PersonId);
     return View(aboutperson);
 }