Example #1
0
		public void ViewOrganisationTest()
		{
			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns(() => 
				new OperationResult<List<Organisation>>() 
				{ 
					Result = new List<Organisation> { new Organisation { Name = "Test" } } 
				});
			ClientManager.RubezhService = mock.Object;

			var organisationsViewModel = new OrganisationsViewModel();
			organisationsViewModel.Initialize(LogicalDeletationType.All);
			Assert.IsTrue(organisationsViewModel.Organisations.Count == 1);
			Assert.IsTrue(organisationsViewModel.SelectedOrganisation.Organisation.Name == "Test");
			Assert.IsTrue(organisationsViewModel.OrganisationDoorsViewModel.Items.Count == 0);
			Assert.IsTrue(organisationsViewModel.OrganisationUsersViewModel.Items.Count == 1);
			Assert.IsTrue(organisationsViewModel.OrganisationUsersViewModel.Items[0].IsChecked == false);
		}
Example #2
0
		public HRViewModel(SKDTabItems skdTabItems)
		{
			SKDTabItems = skdTabItems;
			EditFilterCommand = new RelayCommand(OnEditFilter, CanEditFilter);
			ChangeIsDeletedCommand = new RelayCommand(OnChangeIsDeleted, CanChangeIsDeleted);
			EmployeesViewModel = new EmployeesViewModel();
			DepartmentsViewModel = new DepartmentsViewModel();
			PositionsViewModel = new PositionsViewModel();
			AdditionalColumnTypesViewModel = new AdditionalColumnTypesViewModel();
			CardsViewModel = new CardsViewModel();
			AccessTemplatesViewModel = new AccessTemplatesViewModel();
			PassCardTemplatesViewModel = new PassCardTemplatesViewModel();
			OrganisationsViewModel = new OrganisationsViewModel();
			DepartmentFilter = new DepartmentFilter();
			PositionFilter = new PositionFilter();
			CardFilter = new CardFilter();
			if (CanSelectEmployees) 
				IsEmployeesSelected = true;
			else if (CanSelectDepartments) 
				IsDepartmentsSelected = true;
			else if (CanSelectPositions) 
				IsPositionsSelected = true;
			else if (CanSelectAdditionalColumns) 
				IsAdditionalColumnTypesSelected = true;
			else if (CanSelectCards) 
				IsCardsSelected = true;
			else if (CanSelectAccessTemplates) 
				IsAccessTemplatesSelected = true;
			else if (CanSelectPassCardTemplates) 
				IsPassCardTemplatesSelected = true;
			else if (CanSelectOrganisations) 
				IsOrganisationsSelected = true;
			PersonTypes = new ObservableCollection<PersonType>();
			if (ClientManager.CurrentUser.HasPermission(PermissionType.Oper_SKD_Employees_View))
				PersonTypes.Add(PersonType.Employee);
			if (ClientManager.CurrentUser.HasPermission(PermissionType.Oper_SKD_Guests_View))
				PersonTypes.Add(PersonType.Guest);
			_selectedPersonType = PersonTypes.FirstOrDefault();
			var user = ClientManager.CurrentUser;
			Filter = new HRFilter() { User = user };
			Filter.EmployeeFilter.User = user;
		}
		public OrganisationDetailsViewModel(OrganisationsViewModel organisationsViewModel, Organisation organisation = null)
		{
			OrganisationsViewModel = organisationsViewModel;
			if (organisation == null)
			{
				IsNew = true;
				Title = "Создание новой организации";
				OrganisationDetails = new OrganisationDetails()
				{
					Name = "Организация",
				};
				OrganisationDetails.UserUIDs.Add(ClientManager.CurrentUser.UID);
			}
			else
			{
				Title = string.Format("Свойства организации: {0}", organisation.Name);
				OrganisationDetails = OrganisationHelper.GetDetails(organisation.UID);

			}
			CopyProperties();
			ChiefViewModel = new EmployeeSelectationViewModel(OrganisationDetails.ChiefUID, new EmployeeFilter { OrganisationUIDs = new List<Guid> { OrganisationDetails.UID } });
			HRChiefViewModel = new EmployeeSelectationViewModel(OrganisationDetails.HRChiefUID, new EmployeeFilter { OrganisationUIDs = new List<Guid> { OrganisationDetails.UID } });
		}
Example #4
0
		public void AddOrganisationTest()
		{
			User.PermissionStrings.Add("Oper_SKD_Organisations_AddRemove");
			MockDialogService.OnShowModal += x =>
			{
				var organisationDetailsViewModel = x as OrganisationDetailsViewModel;
				organisationDetailsViewModel.Name = "Test";
				organisationDetailsViewModel.SaveCommand.Execute();

			};

			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns(() => new OperationResult<List<Organisation>>() { Result = new List<Organisation>() });
			mock.Setup(x => x.GetEmployeeList(It.IsAny<EmployeeFilter>())).Returns(() => new OperationResult<List<ShortEmployee>>() { Result = new List<ShortEmployee>() });
			mock.Setup(x => x.SaveOrganisation(It.IsAny<OrganisationDetails>(), It.IsAny<bool>())).Returns(() => new OperationResult<bool>() { Result = true });
			ClientManager.RubezhService = mock.Object;

			var organisationsViewModel = new OrganisationsViewModel();
			organisationsViewModel.Initialize(LogicalDeletationType.All);
			organisationsViewModel.AddCommand.Execute();
			Assert.IsTrue(organisationsViewModel.Organisations.Count == 1);
			Assert.IsTrue(organisationsViewModel.SelectedOrganisation.Organisation.Name == "Test");
		}
Example #5
0
		public void UnSetCurrentUserTest()
		{
			var user1 = new User{ Login = "adm1" };
			var user2 = new User{ Login = "adm2" };
			ClientManager.SecurityConfiguration.Users = new List<RubezhAPI.Models.User>{ user1, user2 };
			ClientManager._userLogin = "adm1";
			var organisation = new Organisation();
			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns<OrganisationFilter>(filter =>
			{
				return new OperationResult<List<Organisation>>(new List<Organisation> { organisation });
			});
			ClientManager.RubezhService = mock.Object;

			var organisationsViewModel = new OrganisationsViewModel();
			organisationsViewModel.Initialize(LogicalDeletationType.All);
			var organisationViewModel = organisationsViewModel.Organisations.FirstOrDefault();
			var currentUserViewModel = organisationsViewModel.OrganisationUsersViewModel.Items.FirstOrDefault(x => x.User.UID == ClientManager.CurrentUser.UID);
			Assert.IsFalse(currentUserViewModel.CanChange);
			var otherUserViewModel = organisationsViewModel.OrganisationUsersViewModel.Items.FirstOrDefault(x => x.User.UID != ClientManager.CurrentUser.UID);
			Assert.IsTrue(otherUserViewModel.CanChange);
		}