public ActionResult Create(ContactInfoPersonRel contactinfopersonrel) { ViewBag.CommonPersonId = contactinfopersonrel.PersonId; if (ModelState.IsValid) { _contactInfoPersonRelRepo.InsertOrUpdate(contactinfopersonrel); _contactInfoPersonRelRepo.Save(); // return RedirectToAction("Details", "Persons", new { id = contactinfopersonrel.PersonId }); } return(View(contactinfopersonrel)); }
public void InsertOrUpdate(ContactInfoPersonRel contactinfopersonrel) { if (contactinfopersonrel.Id == default(int)) { // New entity context.ContactInfo.Add(contactinfopersonrel.ContactInfo); context.ContactInfoPersonRels.Add(contactinfopersonrel); } else { // Existing entity context.Entry(contactinfopersonrel).State = EntityState.Modified; context.Entry(contactinfopersonrel.ContactInfo).State = EntityState.Modified; } }
//// //// GET: /ContactInfoPersonRels/ //public ViewResult Index() //{ // return View(_contactInfoPersonRelRepo.AllIncluding(contactinfopersonrel => contactinfopersonrel.ContactInfo, contactinfopersonrel => contactinfopersonrel.ContactInfoType, contactinfopersonrel => contactinfopersonrel.PrimaryStatus).Take(10)); //} //// //// GET: /ContactInfoPersonRels/Details/5 //public ViewResult Details(int id) //{ // return View(_contactInfoPersonRelRepo.Find(id)); //} // // GET: /ContactInfoPersonRels/Create public ActionResult Create(int personId) { //var person = context.BeholderPersons.Find(personId); //var person = _beholderPersonRepo.Find(personId); var contactInfo = new ContactInfoPersonRel { PersonId = personId, ContactInfo = new ContactInfo() }; if (Request.IsAjaxRequest()) { return(PartialView("_CreateOrEdit", contactInfo)); } return(View(contactInfo)); }