private void CreateFoldersOnDisk(Organization organization)
        {
            using (var uow = new UnitOfWork())
            {
                var baseDir = ConfigurationManager.AppSettings["AppAssetPath"];
                var libraryFolders = uow.GetRepository<LibraryFolder>().Items.Where(x => x.OrganizationId == organization.Id).ToList();

                if (!Directory.Exists(baseDir))
                {
                    FileServiceProvider.CreateDirectory(baseDir, organization.Id.ToString());
                }
                var baseAppPathForOrg = Path.Combine(baseDir, organization.Id.ToString());
                foreach (var libraryFolder in libraryFolders)
                {
                    var appAssetPath = Path.Combine(baseAppPathForOrg, libraryFolder.FolderName);
                    FileServiceProvider.CreateDirectory(appAssetPath);
                }
            }
        }
 private void UpdateOrgInUser(Organization organization)
 {
     using (var uow = new UnitOfWork())
     {
         var userFromDb = uow.GetRepository<User>().Items.FirstOrDefault(x => x.Id == organization.CreatedBy);
         userFromDb.OrganizationId = organization.Id;
         userFromDb.UpdatedBy = organization.CreatedBy;
         userFromDb.UpdatedDate = DateTime.Now;
         userFromDb.IsOrgSuperAdmin = true;
         userFromDb.AdminApprove = true;
         uow.GetRepository<User>().Update(userFromDb);
         uow.SaveChanges();
     }
 }
Beispiel #3
0
 public Organization AddOrganization(Organization organization)
 {
     var organizations = _userRepository.AddOrganization(organization);
     //TODO:Send Email to Prescripds Super Admin
     return organizations;
 }
        public Organization AddOrganization(Organization organization)
        {
            using (var uow = new UnitOfWork())
            {

                if (organization.LibraryFolders != null)
                {
                    var libFolders = CreateDefaultFolder(organization.LibraryFolders);
                    organization.LibraryFolders = libFolders;
                    organization.LibraryFolders.SelectMany(x => x.LibraryAssets)
                        .Each(la => uow.GetRepository<LibraryAsset>().Items.ToList().Add(la));
                    organization.LibraryFolders.SelectMany(x => x.LibraryAssets)
                        .SelectMany(lf => lf.LibraryAssetFiles)
                        .Each(laf => uow.GetRepository<LibraryAssetFile>().Items.ToList().Add(laf));
                }
                uow.GetRepository<Organization>().Insert(organization);
                uow.SaveChanges();
                UpdateOrgInUser(organization);
                CreateFoldersOnDisk(organization);

                return organization;
            }

        }
 public Organization AddOrganization(Organization organization)
 {
     var organizationFromDb = _userBl.AddOrganization(organization);
     return organizationFromDb;
 }