예제 #1
0
        public void RemoveOrganization(Organization org)
        {
            PhoneNumberRepository.RemoveByOrganizationId(org.Id);
            OrganizationFilesRepositiry.RemoveByOrganizationId(org.Id);
            AdditionalInfoRepository.RemoveByOrganizationId(org.Id); //Удаляем всю информацию, связанную с организацией

            OrganizationRepository.RemoveByOrganizationId(org.Id);   //удаляем саму организацию
        }
예제 #2
0
 public Db()
 {
     GetConnection();
     OrganizationRepository      = new OrganizationRepository(_conn);
     PhoneNumberRepository       = new PhoneNumberRepository(_conn);
     AdditionalInfoRepository    = new AdditionalInfoRepository(_conn);
     OrganizationFilesRepositiry = new OrganizationFilesRepositiry(_conn);
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
 public void LoadOrganizationData(Organization org)
 {
     org.PhoneNumbers      = PhoneNumberRepository.GetPhoneNumbersByOrganizationId(org.Id);
     org.AdditionalInfos   = AdditionalInfoRepository.GetAdditionalInfosByOrganizationId(org.Id);
     org.OrganizationFiles = OrganizationFilesRepositiry.GetFilesByOrganizationId(org.Id);
 }