Beispiel #1
0
        private void Start()
        {
            if (IsRegistration())
            {
                try
                {
                    UserManagement userManagement = new UserManagement();
                    if (userManagement.IsFirstUser())
                    {
                        var regForm = new Views.Registration();
                        regForm.ShowDialog();
                        var regVM = (Views.RegistrationViewModel)regForm.DataContext;
                        if (regVM.UserCreated != null)
                        {
                            Helpers.UserLogin = regVM.UserCreated;
                            if (!userManagement.IsRoleExist("Administrator").Result)
                            {
                                userManagement.AddNewRole("Administrator");
                            }

                            if (!userManagement.IsRoleExist("Manager").Result)
                            {
                                userManagement.AddNewRole("Manager");
                            }

                            if (!userManagement.IsRoleExist("Admin").Result)
                            {
                                userManagement.AddNewRole("Admin");
                            }

                            if (!userManagement.IsRoleExist("Operational").Result)
                            {
                                userManagement.AddNewRole("Operational");
                            }

                            if (!userManagement.IsRoleExist("Accounting").Result)
                            {
                                userManagement.AddNewRole("Accounting");
                            }

                            userManagement.AddUserInRole(Helpers.UserLogin.Id, "Administrator");

                            var setting = new Views.Setting();
                            setting.ShowDialog();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Helpers.ShowErrorMessage(ex.Message);
                    this.Close();
                }
            }
            else
            {
                this.Close();
            }
        }
Beispiel #2
0
        private void AddNewUserAction(object obj)
        {
            var form = new Views.Registration();

            form.ShowDialog();
            var vm = (Views.RegistrationViewModel)form.DataContext;

            if (vm.UserCreated != null)
            {
                Source.Add(vm.UserCreated);
                UserSelected = vm.UserCreated;
            }
        }