public Person AddPerson(Person aPerson) { using (var tran = Repository.BeginTran()) { var entity = Repository.Create(_simpleMapper.Map<Person, Data.Entities.Person>(aPerson)); aPerson.Id = entity.Id; tran.Commit(); } return aPerson; }
public Person Put(int id, Person person) { person.Id = id; return PersonService.SavePerson(person); }
public Person SavePerson(Person aPerson) { using (var tran = Repository.BeginTran()) { var entity = Repository.Get().OfType<Data.Entities.Person>().Single(x => x.Id == aPerson.Id); entity.BirthDate = DateTime.Parse(aPerson.BirthDate); entity.Description = aPerson.Description; entity.FirstName = aPerson.FirstName; entity.Gender = (int)aPerson.Gender; entity.LastName = aPerson.LastName; entity.Name = string.Format("{0} {1}", aPerson.FirstName, aPerson.LastName); entity = (Data.Entities.Person)Repository.Save(entity); tran.Commit(); return _simpleMapper.Map<Data.Entities.Person, Person>(entity); } }
public Person Post(Person person) { return PersonService.AddPerson(person); }