public bool InsertOrUpdate(Person person)
        {
            if (person.PersonId == default(int)) {
                // New entity
                context.People.AddObject(person);

            } else {
                // Existing entity
				if(person.EntityState == System.Data.EntityState.Detached)
				{
					context.People.Attach(person);
					context.ObjectStateManager.ChangeObjectState(person, System.Data.EntityState.Modified);
				}
            }

			return this.Save() > 0;
        }
 /// <summary>
 /// Create a new Person object.
 /// </summary>
 /// <param name="personId">Initial value of the PersonId property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="doB">Initial value of the DoB property.</param>
 /// <param name="genderID">Initial value of the GenderID property.</param>
 public static Person CreatePerson(global::System.Int32 personId, global::System.String firstName, global::System.String lastName, global::System.DateTime doB, global::System.Int32 genderID)
 {
     Person person = new Person();
     person.PersonId = personId;
     person.FirstName = firstName;
     person.LastName = lastName;
     person.DoB = doB;
     person.GenderID = genderID;
     return person;
 }
		public ActionResult CreateOrEdit(Person person)
		{
			if (ModelState.IsValid &&  Repository_person.InsertOrUpdate(person)) 
				return Content("SUCCESS");

			return PartialView(person);	
		}
 /// <summary>
 /// Deprecated Method for adding a new object to the People EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPeople(Person person)
 {
     base.AddObject("People", person);
 }