public void RemoveOrganization(Organization org) { PhoneNumberRepository.RemoveByOrganizationId(org.Id); OrganizationFilesRepositiry.RemoveByOrganizationId(org.Id); AdditionalInfoRepository.RemoveByOrganizationId(org.Id); //Удаляем всю информацию, связанную с организацией OrganizationRepository.RemoveByOrganizationId(org.Id); //удаляем саму организацию }
public Db() { GetConnection(); OrganizationRepository = new OrganizationRepository(_conn); PhoneNumberRepository = new PhoneNumberRepository(_conn); AdditionalInfoRepository = new AdditionalInfoRepository(_conn); OrganizationFilesRepositiry = new OrganizationFilesRepositiry(_conn); }
public void EditOrganization(Organization org) { OrganizationRepository.Edit(org); int id = org.Id; foreach (var phone in org.PhoneNumbersToAdd) { phone.OrganizaionId = id; PhoneNumberRepository.Add(phone); } foreach (var phone in org.PhoneNumbersToEdit) { PhoneNumberRepository.Edit(phone); } foreach (var phone in org.PhoneNumbersToRemove) { PhoneNumberRepository.Remove(phone); } foreach (var info in org.AdditionalInfosToAdd) { info.OrganizaionId = id; AdditionalInfoRepository.Add(info); } foreach (var info in org.AdditionalInfosToEdit) { AdditionalInfoRepository.Edit(info); } foreach (var info in org.AdditionalInfosToRemove) { AdditionalInfoRepository.Remove(info); } foreach (var file in org.OrganizationFilesToAdd) { file.OrganizaionId = id; OrganizationFilesRepositiry.Add(file); } foreach (var file in org.OrganizationFilesToRemove) { deleteFile(file.Path); OrganizationFilesRepositiry.Remove(file); } }
public int AddOrganization(Organization org) { int id = OrganizationRepository.Add(org); foreach (var phone in org.PhoneNumbersToAdd) { phone.OrganizaionId = id; PhoneNumberRepository.Add(phone); } foreach (var info in org.AdditionalInfosToAdd) { info.OrganizaionId = id; AdditionalInfoRepository.Add(info); } foreach (var file in org.OrganizationFilesToAdd) { file.OrganizaionId = id; OrganizationFilesRepositiry.Add(file); } return(id); }
public void LoadOrganizationData(Organization org) { org.PhoneNumbers = PhoneNumberRepository.GetPhoneNumbersByOrganizationId(org.Id); org.AdditionalInfos = AdditionalInfoRepository.GetAdditionalInfosByOrganizationId(org.Id); org.OrganizationFiles = OrganizationFilesRepositiry.GetFilesByOrganizationId(org.Id); }