Ejemplo n.º 1
0
        internal AppUserVm(User user, IEnumerable <string> roleNames, bool isAuthenticated = false)
        {
            _username        = user.UserName;
            _isAuthenticated = isAuthenticated;

            // Default user information
            Id             = user.Id;
            Email          = user.Email;
            EmailConfirmed = user.EmailConfirmed;

            // User profile information
            FirstName           = user.UserProfile.FirstName;
            LastName            = user.UserProfile.LastName;
            Bio                 = user.UserProfile.Bio;
            SubscribeNewsletter = user.UserProfile.SubscribeNewsletter;

            // Tokens
            PasswordResetToken     = user.PasswordResetToken;
            EmailConfirmationToken = user.EmailConfirmationToken;

            if (user.EmailConfirmed && isAuthenticated)
            {
                SignInStatus = SignInStatus.Success;
            }
            else if (!user.EmailConfirmed && isAuthenticated)
            {
                SignInStatus = SignInStatus.RequiresVerification;
            }
            else
            {
                SignInStatus = SignInStatus.Failed;
            }

            Roles.AddRange(roleNames);
        }
Ejemplo n.º 2
0
        internal override void parseJObject(JObject obj)
        {
            base.parseJObject(obj);
            JToken token = obj.GetValue("Identification", StringComparison.InvariantCultureIgnoreCase);

            if (token != null)
            {
                Identification = token.Value <string>();
            }
            token = obj.GetValue("FamilyName", StringComparison.InvariantCultureIgnoreCase);
            if (token != null)
            {
                FamilyName = token.Value <string>();
            }
            token = obj.GetValue("GivenName", StringComparison.InvariantCultureIgnoreCase);
            if (token != null)
            {
                GivenName = token.Value <string>();
            }
            JArray array = obj.GetValue("MiddleName", StringComparison.InvariantCultureIgnoreCase) as JArray;

            if (array != null)
            {
                foreach (string s in array.Values <string>())
                {
                    AddMiddleName(s);
                }
            }
            Roles.AddRange(mDatabase.extractJArray <IfcActorRole>(obj.GetValue("Roles", StringComparison.InvariantCultureIgnoreCase) as JArray));
            Addresses.AddRange(mDatabase.extractJArray <IfcAddress>(obj.GetValue("Addresses", StringComparison.InvariantCultureIgnoreCase) as JArray));
        }
        public ProfileViewModel(Account account, IEnumerable <Role> roles)
        {
            this.Id          = account.Id;
            this.Email       = account.Email;
            this.FirstName   = account.FirstName;
            this.LastName    = account.LastName;
            this.PhoneNumber = account.PhoneNumber;
            this.Addresses   = account.Address;
            this.Role        = account.Role;

            foreach (var role in roles)
            {
                if (role.RoleName == this.Role.RoleName)
                {
                    SelectListItem listItem = new SelectListItem()
                    {
                        Value = role.Id.ToString(),
                        Text  = role.RoleName
                    };
                    CurrentRole.Add(listItem);
                }
                else
                {
                    SelectListItem listItem = new SelectListItem()
                    {
                        Value = role.Id.ToString(),
                        Text  = role.RoleName
                    };
                    OtherRole.Add(listItem);
                }
            }

            Roles.AddRange(CurrentRole);
            Roles.AddRange(OtherRole);
        }
Ejemplo n.º 4
0
 internal override void parse(string str, ref int pos, ReleaseVersion release, int len, ConcurrentDictionary <int, BaseClassIfc> dictionary)
 {
     mIdentification = ParserSTEP.StripString(str, ref pos, len);
     mName           = ParserSTEP.StripString(str, ref pos, len);
     mDescription    = ParserSTEP.StripString(str, ref pos, len);
     Roles.AddRange(ParserSTEP.StripListLink(str, ref pos, len).ConvertAll(x => dictionary[x] as IfcActorRole));
     mAddresses.AddRange(ParserSTEP.StripListLink(str, ref pos, len).ConvertAll(x => dictionary[x] as IfcAddress));
 }
            public static Roles FromString(string value)
            {
                Roles result = new Roles();

                string[] roles = value.ToString().Split(',');

                result.AddRange(roles.Select(r => new Role(r)));

                return(result);
            }
Ejemplo n.º 6
0
        private void InitBaseDataIfDatabaseEmpty()
        {
            if (!Roles.Any())
            {
                Roles.AddRange(RolesFactory.GetAllRoles());
            }

            if (!Apps.Any())
            {
                Apps.AddRange(AppsFactory.GetApps());
            }
        }
Ejemplo n.º 7
0
 public EditUserModel(string employeeId)
 {
     if (!string.IsNullOrEmpty(employeeId))
     {
         UserObject o = UserObject.GetUser(employeeId);
         if (o != null)
         {
             EmployeeId = o.EmployeeId;
             Roles.AddRange(o.Roles);
             Name = o.FullName;
         }
     }
 }
Ejemplo n.º 8
0
        public void Seed()
        {
            try
            {
                Server server = new Server()
                {
                    Prefix = "!", DiscordID = 0, Name = "Game Data Server"
                };
                Servers.Add(server);
                SaveChanges();

                IList <Role> roles = new List <Role>()
                {
                    new Role()
                    {
                        Name = "Admin", Description = "Application / Bot Admin"
                    },
                    new Role()
                    {
                        Name = "ServerOwner", Description = "Discord Server Owner"
                    },
                    new Role()
                    {
                        Name = "GM", Description = "Game Master"
                    }
                };
                roles[0].Claims.Add(new RoleClaim()
                {
                    Role = roles[0], ClaimType = "AuthorizationLevel", ClaimValue = "Admin"
                });
                roles[1].Claims.Add(new RoleClaim()
                {
                    Role = roles[1], ClaimType = "AuthorizationLevel", ClaimValue = "ServerOwner"
                });
                roles[2].Claims.Add(new RoleClaim()
                {
                    Role = roles[2], ClaimType = "AuthorizationLevel", ClaimValue = "GM"
                });
                Roles.AddRange(roles);
                SaveChanges();

                // Everything went fine so commit
            }
            catch (Exception e)
            {
                Console.WriteLine($"Seeding failed: {e.Message}\n{e.StackTrace}");
            }
        }
Ejemplo n.º 9
0
 private async void GetUsersMethod()
 {
     Users.Clear();
     Users.AddRange(await _database.Users
                    .Where(u => u.UserRoles.FirstOrDefault().RoleId != Constants.AdministratorRole)
                    .Select(u => new UserRoleManagementModel {
         DefaultRoleId = u.UserRoles.FirstOrDefault().RoleId,
         Login         = u.Login,
         UserId        = u.Id,
         UserName      = u.Name + " " + u.Surname,
         RoleId        = u.UserRoles.FirstOrDefault().RoleId,
         HasChanges    = false
     }).ToListAsync());
     Roles.Clear();
     Roles.AddRange(await _database.Roles.ToListAsync());
 }
Ejemplo n.º 10
0
        internal override void parseJObject(JObject obj)
        {
            base.parseJObject(obj);
            JToken token = obj.GetValue("ThePerson", StringComparison.InvariantCultureIgnoreCase);

            if (token != null)
            {
                ThePerson = mDatabase.ParseJObject <IfcPerson>(token as JObject);
            }
            token = obj.GetValue("TheOrganization", StringComparison.InvariantCultureIgnoreCase);
            if (token != null)
            {
                TheOrganization = mDatabase.ParseJObject <IfcOrganization>(token as JObject);
            }
            Roles.AddRange(mDatabase.extractJArray <IfcActorRole>(obj.GetValue("Roles", StringComparison.InvariantCultureIgnoreCase) as JArray));
        }
Ejemplo n.º 11
0
        public LibraryContext(DbContextOptions <LibraryContext> options)
            : base(options)
        {
            Database.EnsureCreated();



            if (Roles.Count() == 0)
            {
                Roles.AddRange(
                    new IdentityRole {
                    Name = "Admin", NormalizedName = "ADMIN"
                },
                    new IdentityRole {
                    Name = "User", NormalizedName = "USER"
                }
                    );
            }
        }
Ejemplo n.º 12
0
        public async Task Load()
        {
            try
            {
                this.Loading = true;
                var users = await _roleRepository.GetAll();

                var mappedRoles = users.Select(_mapper.Map <RoleListItemDto>).ToList();
                ApplicationDispatcher.Invoke(() => Roles.AddRange(mappedRoles));
            }
            catch (Exception ex)
            {
                _messageDialog.ShowError(title: General.ErrorLoadingRolesTitle, message: ex.Message);
            }
            finally
            {
                this.Loading = false;
            }
        }
Ejemplo n.º 13
0
        internal override void parseJObject(JObject obj)
        {
            base.parseJObject(obj);
            JToken token = obj.GetValue("Identification", StringComparison.InvariantCultureIgnoreCase);

            if (token != null)
            {
                Identification = token.Value <string>();
            }
            token = obj.GetValue("Name", StringComparison.InvariantCultureIgnoreCase);
            if (token != null)
            {
                Name = token.Value <string>();
            }
            token = obj.GetValue("Description", StringComparison.InvariantCultureIgnoreCase);
            if (token != null)
            {
                Description = token.Value <string>();
            }
            Roles.AddRange(mDatabase.extractJArray <IfcActorRole>(obj.GetValue("Roles", StringComparison.InvariantCultureIgnoreCase) as JArray));
            Addresses.AddRange(mDatabase.extractJArray <IfcAddress>(obj.GetValue("Addresses", StringComparison.InvariantCultureIgnoreCase) as JArray));
        }
Ejemplo n.º 14
0
 public void AddRoles(params string[] roles)
 {
     Roles.AddRange(roles);
 }
 public void AddRoles(List <IoCRole> roles) =>
 Roles.AddRange(roles);
 public void Seed(params Role[] seed)
 {
     Roles.AddRange(seed);
 }
Ejemplo n.º 17
0
 public MenuItem(params string[] roles)
 {
     Roles.AddRange(roles);
 }
 /// <summary>
 /// Retrieves the roles.
 /// </summary>
 /// <returns></returns>
 public override Roles RetrieveRoles()
 {
     Roles roles = new Roles();
     using (this.dbContext = new BuildMotionDb(this.connectionStringName))
     {
         roles.AddRange(this.dbContext.Roles);
     }
     return roles;
 }
Ejemplo n.º 19
0
        public PersonsContext()
        {
            // добавляем строки для первоначальной заполненности

            if (Persons.Count() != 0)
            {
                return;
            }
            Persons.AddRange(
                new Person()
            {
                Login    = "******",
                Password = "******",
                Name     = "Михаил Борисович",
                Email    = "*****@*****.**"
            },
                new Person()
            {
                Login    = "******",
                Password = "******",
                Name     = "Борис Анатольевич",
                Email    = "*****@*****.**"
            },
                new Person()
            {
                Login    = "******",
                Password = "******",
                Name     = "Наташа",
                Email    = "*****@*****.**"
            },
                new Person()
            {
                Login    = "******",
                Password = "******",
                Name     = "admin",
                Email    = "*****@*****.**"
            });

            Roles.AddRange(
                new Role()
            {
                Name = "Администратор"
            },
                new Role()
            {
                Name = "Заказчик"
            },
                new Role()
            {
                Name = "Специалист отдела кадров"
            },
                new Role()
            {
                Name = "Бухгалтер"
            });

            SaveChanges();

            PersonsRoles.AddRange(
                new PersonsRoles()
            {
                PersonId = 1,
                RoleId   = 1,
            },
                new PersonsRoles()
            {
                PersonId = 2,
                RoleId   = 2,
            },
                new PersonsRoles()
            {
                PersonId = 3,
                RoleId   = 3,
            },
                new PersonsRoles()
            {
                PersonId = 3,
                RoleId   = 4,
            },
                new PersonsRoles()
            {
                PersonId = 4,
                RoleId   = 1,
            });

            SaveChanges();
        }
Ejemplo n.º 20
0
 private void DataMigration()
 {
     if (Roles.CountAsync().Result == 0)
     {
         var roles = new List <Roles>()
         {
             new Roles()
             {
                 Name           = "Developer",
                 NormalizedName = "DEVELOPER",
                 DomainFid      = "K140Q2XAJAAF"
             },
             new Roles()
             {
                 Name           = "Super Administrator",
                 NormalizedName = "SUPERADMINISTRATOR",
                 DomainFid      = "K140Q2XAJAAF"
             },
             new Roles()
             {
                 Name           = "Dining Administrator",
                 NormalizedName = "DININGADMINISTRATOR",
                 DomainFid      = "K140Q2XAJAAF"
             },
             new Roles()
             {
                 Name           = "Dining Merchant Manager",
                 NormalizedName = "DININGMERCHANTMANAGER",
                 DomainFid      = "K140Q2XAJAAF"
             },
             new Roles()
             {
                 Name           = "Dining Merchant",
                 NormalizedName = "DININGMERCHANT",
                 DomainFid      = "K140Q2XAJAAF"
             },
             new Roles()
             {
                 Name           = "Yacht Administrator",
                 NormalizedName = "YACHTADMINISTRATOR",
                 DomainFid      = "K140Q2XAJAAF"
             },
             new Roles()
             {
                 Name           = "Yacht Merchant Manager",
                 NormalizedName = "YACHTMERCHANTMANAGER",
                 DomainFid      = "K140Q2XAJAAF"
             },
             new Roles()
             {
                 Name           = "Yacht Merchant",
                 NormalizedName = "YACHTMERCHANT",
                 DomainFid      = "K140Q2XAJAAF"
             },
         };
         Roles.AddRange(roles);
         SaveChanges();
     }
     if (RoleControls.CountAsync().Result == 0)
     {
         var rolecontrolls = new List <RoleControls>()
         {
             new RoleControls()
             {
                 SuperiorFid    = 1,
                 SubordinateFid = 2
             },
             new RoleControls()
             {
                 SuperiorFid    = 1,
                 SubordinateFid = 3
             },
             new RoleControls()
             {
                 SuperiorFid    = 1,
                 SubordinateFid = 4
             },
             new RoleControls()
             {
                 SuperiorFid    = 1,
                 SubordinateFid = 5
             }, new RoleControls()
             {
                 SuperiorFid    = 1,
                 SubordinateFid = 6
             }, new RoleControls()
             {
                 SuperiorFid    = 1,
                 SubordinateFid = 7
             },
             new RoleControls()
             {
                 SuperiorFid    = 1,
                 SubordinateFid = 8
             },
             new RoleControls()
             {
                 SuperiorFid    = 5,
                 SubordinateFid = 3
             },
             new RoleControls()
             {
                 SuperiorFid    = 5,
                 SubordinateFid = 4
             },
             new RoleControls()
             {
                 SuperiorFid    = 5,
                 SubordinateFid = 6
             },
             new RoleControls()
             {
                 SuperiorFid    = 5,
                 SubordinateFid = 7
             },
             new RoleControls()
             {
                 SuperiorFid    = 5,
                 SubordinateFid = 8
             },
             new RoleControls()
             {
                 SuperiorFid    = 3,
                 SubordinateFid = 4
             },
             new RoleControls()
             {
                 SuperiorFid    = 3,
                 SubordinateFid = 5
             },
             new RoleControls()
             {
                 SuperiorFid    = 3,
                 SubordinateFid = 6
             },
             new RoleControls()
             {
                 SuperiorFid    = 3,
                 SubordinateFid = 7
             },
         };
         RoleControls.AddRange(rolecontrolls);
         base.SaveChanges();
     }
 }
Ejemplo n.º 21
0
        private void InitialInitialization()
        {
            List <CategoryEntity> categories = new List <CategoryEntity>()
            {
                new CategoryEntity()
                {
                    Name = "Категория-1"
                },
                new CategoryEntity()
                {
                    Name = "Категория-2"
                },
                new CategoryEntity()
                {
                    Name = "Категория-3"
                }
            };



            List <RoleEntity> roles = new List <RoleEntity>()
            {
                new RoleEntity()
                {
                    Name = "Operator"
                },
                new RoleEntity()
                {
                    Name = "Customer"
                }
            };

            List <GenderEntity> genders = new List <GenderEntity>()
            {
                new GenderEntity()
                {
                    Name = "Male"
                },
                new GenderEntity()
                {
                    Name = "Female"
                }
            };

            UserEntity user = new UserEntity()
            {
                Email    = "*****@*****.**",
                Password = "******", //TODO hash этого пароля test
                Role     = roles[1],
                Name     = "Test",
                LastName = "Test",
                Gender   = genders[0]
            };

            Categories.AddRange(categories);


            Roles.AddRange(roles);
            Genders.AddRange(genders);
            Users.Add(user);
            SaveChanges();

            List <SubCategoryEntity> subCategories = new List <SubCategoryEntity>()
            {
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-1-1", CategoryId = categories[0].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-1-2", CategoryId = categories[0].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-1-3", CategoryId = categories[0].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-2-1", CategoryId = categories[1].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-2-2", CategoryId = categories[1].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-2-3", CategoryId = categories[1].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-3-1", CategoryId = categories[2].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-3-2", CategoryId = categories[2].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-3-3", CategoryId = categories[2].Id
                }
            };

            SubCategories.AddRange(subCategories);
            SaveChanges();
        }
Ejemplo n.º 22
0
        public System.Web.Operator GetOperator(string username)
        {
            System.Web.Operator optr = new System.Web.Operator();
            SecurityDataContext context = new SecurityDataContext();

            var acct = context.Accounts.Where(a => a.UserName == username).FirstOrDefault();

            if (acct != null)
            {
                optr.Id = acct.Id;
                optr.UserName = acct.UserName;
                optr.Email = acct.Email;
                optr.PersonId = acct.ProfileId;
                optr.IsDisabled = acct.IsDeleted.HasValue ? acct.IsDeleted.Value : false;

                Roles roles = new Roles();
                if (acct != null)
                {
                    roles.AddRange(GetRoles(acct.Id));
                    optr.Roles = roles;
                }
            }

            return optr;
        }