private void updatePhone(Person person, Person updatedPerson, int phoneType, IFootlooseFSUnitOfWork unitOfWork) { var updatePhone = updatedPerson.Phones.Where(p => p.PhoneTypeID == phoneType).FirstOrDefault(); if (updatePhone == null) { var phone = person.Phones.Where(p => p.PhoneTypeID == phoneType).FirstOrDefault(); if (phone != null) { unitOfWork.Phones.Delete(phone); } } else { var phone = person.Phones.Where(p => p.PhoneTypeID == phoneType).FirstOrDefault(); if (phone == null) { phone = new Phone(); phone.PersonID = updatePhone.PersonID; phone.PhoneTypeID = updatePhone.PhoneTypeID; person.Phones.Add(phone); } phone.Number = updatePhone.Number; } }
public PersonRepository(DbContext dbContext, IFootlooseFSUnitOfWork unitOfWork) : base(dbContext) { _unitOfWork = unitOfWork; }
private void updateAddress(Person person, Person updatedPerson, int addressType, IFootlooseFSUnitOfWork unitOfWork) { var updatedAddressAssn = updatedPerson.Addresses.Where(a => a.AddressTypeID == addressType).FirstOrDefault(); if (updatedAddressAssn == null) { var addressAssn = person.Addresses.Where(a => a.AddressTypeID == addressType).FirstOrDefault(); if (addressAssn != null) { unitOfWork.Addresses.Delete(addressAssn.Address); unitOfWork.PersonAddressAssns.Delete(addressAssn); } } else { var addressAssn = person.Addresses.Where(a => a.AddressTypeID == addressType).FirstOrDefault(); if (addressAssn == null) { addressAssn = new PersonAddressAssn(); addressAssn.PersonID = updatedAddressAssn.PersonID; addressAssn.AddressTypeID = updatedAddressAssn.AddressTypeID; addressAssn.Address = new Address(); person.Addresses.Add(addressAssn); } addressAssn.Address.StreetAddress = updatedAddressAssn.Address.StreetAddress; addressAssn.Address.City = updatedAddressAssn.Address.City; addressAssn.Address.State = updatedAddressAssn.Address.State; addressAssn.Address.Zip = updatedAddressAssn.Address.Zip; } }
private void updatePhone(Person person, Person updatedPerson, int phoneType, IFootlooseFSUnitOfWork unitOfWork) { var updatePhone = updatedPerson.Phones.Where(p => p.PhoneTypeID == phoneType).FirstOrDefault(); if (updatePhone == null) { var phone = person.Phones.Where(p => p.PhoneTypeID == phoneType).FirstOrDefault(); if (phone != null) unitOfWork.Phones.Delete(phone); } else { var phone = person.Phones.Where(p => p.PhoneTypeID == phoneType).FirstOrDefault(); if (phone == null) { phone = new Phone(); phone.PersonID = updatePhone.PersonID; phone.PhoneTypeID = updatePhone.PhoneTypeID; person.Phones.Add(phone); } phone.Number = updatePhone.Number; } }