public DataModificationResult DeletePerson(Person person) { try { using (PraetorTestEntities db = new PraetorTestEntities()) { db.Person.Attach(person); db.Person.Remove(person); db.SaveChanges(); return new DataModificationResult() { Result = DataModificationResult.Results.Ok }; } } catch (DbUpdateConcurrencyException ex) { return new DataModificationResult() { Result = DataModificationResult.Results.OptimisticConcurrencyException, ExceptionMessage = ex.Message }; } catch (Exception ex) { return new DataModificationResult() { Result = DataModificationResult.Results.OptimisticConcurrencyException, ExceptionMessage = ex.Message }; } }
public PersonContract(Person person) { if (person != null) { this.ID = person.ID; this.Address = person.Address; this.Birthday = person.Birthday; this.CellPhone = person.CellPhone; this.ChineseName = person.ChineseName; this.Email = person.Email; this.EnglishName = person.EnglishName; this.Male = person.Male; this.NativePlace = person.NativePlace; } }