Example #1
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);
            }
        }
Example #2
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);
        }