Example #1
0
        public void AddOrganizationRole(string name)
        {
            using (LInstContext entities = _dbContextFactory.CreateDbContext(new string[] { }))
            {
                OrganizationRole newRole = new OrganizationRole
                {
                    Name        = name,
                    Description = ""
                };

                entities.OrganizationRoles.Add(newRole);

                foreach (Organization org in entities.Organizations)
                {
                    OrganizationRoleMapping newMapping = new OrganizationRoleMapping
                    {
                        OrganizationRole = newRole,
                        Organization     = org,
                        IsSelected       = false
                    };
                    entities.OrganizationRoleMappings.Add(newMapping);
                }

                entities.SaveChanges();
            }
        }
Example #2
0
        /// <summary>
        /// Creates and inserts in the DB the mappings between a new OrganizationRole
        /// and all the existing organization
        /// </summary>
        /// <param name="newRole">The role for which will be built the mappings</param>
        internal void CreateMappingsForNewRole(OrganizationRole newRole)
        {
            using (LInstContext entities = _dbContextFactory.CreateDbContext(new string[] { }))
            {
                IEnumerable <Organization> _orgList = entities.Organizations.ToList();

                foreach (Organization org in _orgList)
                {
                    OrganizationRoleMapping tempMap = new OrganizationRoleMapping()
                    {
                        IsSelected         = false,
                        OrganizationRoleID = newRole.ID
                    };

                    org.RoleMappings.Add(tempMap);
                }

                entities.SaveChanges();
            }
        }
Example #3
0
        public Organization CreateNewOrganization()
        {
            StringInputDialog creationDialog = new StringInputDialog
            {
                Title = "Crea nuovo Ente"
            };

            if (creationDialog.ShowDialog() == true)
            {
                Organization output = new Organization
                {
                    Category = "",
                    Name     = creationDialog.InputString
                };
                foreach (OrganizationRole orr in _labDbData.RunQuery(new OrganizationRolesQuery()))
                {
                    OrganizationRoleMapping tempORM = new OrganizationRoleMapping
                    {
                        IsSelected = false,
                        RoleID     = orr.ID
                    };

                    output.RoleMapping.Add(tempORM);
                }

                output.Create();

                EntityChangedToken token = new EntityChangedToken(output,
                                                                  EntityChangedToken.EntityChangedAction.Created);
                _eventAggregator.GetEvent <OrganizationChanged>()
                .Publish(token);

                return(output);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        public Organization CreateNewOrganization()
        {
            StringInputDialog creationDialog = new StringInputDialog
            {
                Title = "Crea nuovo Ente"
            };

            if (creationDialog.ShowDialog() == true)
            {
                Organization output = new Organization
                {
                    Name = creationDialog.InputString
                };
                foreach (OrganizationRole orr in _lInstData.RunQuery(new OrganizationRolesQuery()))
                {
                    OrganizationRoleMapping tempORM = new OrganizationRoleMapping
                    {
                        IsSelected         = false,
                        OrganizationRoleID = orr.ID
                    };

                    output.RoleMappings.Add(tempORM);
                }

                _lInstData.Execute(new InsertEntityCommand <LInstContext>(output));

                EntityChangedToken token = new EntityChangedToken(output,
                                                                  EntityChangedToken.EntityChangedAction.Created);
                _eventAggregator.GetEvent <EntityChanged>()
                .Publish(token);

                return(output);
            }
            else
            {
                return(null);
            }
        }