Inheritance: BaseEntity
コード例 #1
0
        public ActionResult Create(Person person)
        {
            if (ModelState.IsValid)
            {
                db.PersonRepository.Insert(person);
                db.Save();
                return RedirectToAction("Index");
            }

            return View(person);
        }
コード例 #2
0
        //
        // GET: /Person/Edit/5
        /// <summary>
        /// This governs both add AND edit, since we're doing basically the same thing for both.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(Int32? id)
        {
            Person person = null;
            if (id == null)
            {
                person = new Person();
            }
            else
            {
                person = db.PersonRepository.Get().FirstOrDefault(x => x.Id == id);
                if (person == null)
                {
                    return HttpNotFound();
                }
            }

            return View(person);
        }
コード例 #3
0
        public ActionResult Edit(Person person)
        {
            if (ModelState.IsValid)
            {
                // Sync phone records.

                if (person.Id == 0)
                {
                    db.PersonRepository.Insert(person);
                }
                else
                {
                    db.PersonRepository.Update(person);
                }
                db.Save();
                return RedirectToAction("Index");
            }
            return View(person);
        }