예제 #1
0
		public TextColumnViewModel(AdditionalColumnType additionalColumnType, Employee employee, AdditionalColumn additionalColumn = null)
		{
			AdditionalColumnType = additionalColumnType;
			Employee = employee;
			AdditionalColumn = additionalColumn != null ? additionalColumn : 
				new AdditionalColumn { AdditionalColumnTypeUID = AdditionalColumnType.UID, ColumnName = AdditionalColumnType.Name, EmployeeUID = Employee.UID, TextData = "" };
		}
예제 #2
0
		public GraphicsColumnViewModel(AdditionalColumnType additionalColumnType, Employee employee, AdditionalColumn additionalColumn = null)
		{
			AdditionalColumnType = additionalColumnType;
			Employee = employee;
			AdditionalColumn = additionalColumn != null ? additionalColumn :
				new AdditionalColumn { AdditionalColumnTypeUID = AdditionalColumnType.UID, ColumnName = additionalColumnType.Name, EmployeeUID = Employee.UID, Photo = new Photo() };
		}
예제 #3
0
		public void AdditionalColumns()
		{
			var organisation1 = new Organisation();
			var organisation2 = new Organisation();
			var employee1 = new ShortEmployee { OrganisationUID = organisation1.UID };
			var employee2 = new ShortEmployee { OrganisationUID = organisation2.UID };
			var additionalColumnType1 = new AdditionalColumnType { OrganisationUID = organisation1.UID, IsInGrid = true, DataType = AdditionalColumnDataType.Text };
			var additionalColumnType2 = new AdditionalColumnType { OrganisationUID = organisation1.UID, IsInGrid = true, DataType = AdditionalColumnDataType.Text };
			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns<OrganisationFilter>(filter =>
				{
					var result = new List<Organisation>();
					if (filter.UIDs.Count == 0)
					{
						result.Add(organisation1);
						result.Add(organisation2);
					}
					if (filter.UIDs.Any(x => x == organisation1.UID))
						result.Add(organisation1);
					if (filter.UIDs.Any(x => x == organisation2.UID))
						result.Add(organisation2);
					return new OperationResult<List<Organisation>>(result);
				});
			mock.Setup(x => x.GetEmployeeList(It.IsAny<EmployeeFilter>())).Returns<EmployeeFilter>(filter =>
				{
					var result = new List<ShortEmployee>();
					if(filter.OrganisationUIDs.Count == 0)
					{
						result.Add(employee1);
						result.Add(employee2);
					}
					if (filter.OrganisationUIDs.Any(x => x == organisation1.UID))
						result.Add(employee1);
					if (filter.OrganisationUIDs.Any(x => x == organisation2.UID))
						result.Add(employee2);
					return new OperationResult<List<ShortEmployee>>(result);
				});
			mock.Setup(x => x.GetAdditionalColumnTypes(It.IsAny<AdditionalColumnTypeFilter>())).Returns<AdditionalColumnTypeFilter>(filter =>
			{
				var result = new List<AdditionalColumnType>();
				if (filter.OrganisationUIDs.Count == 0)
				{
					result.Add(additionalColumnType1);
					result.Add(additionalColumnType2);
				}
				if (filter.OrganisationUIDs.Any(x => x == organisation1.UID))
					result.Add(additionalColumnType1);
				if (filter.OrganisationUIDs.Any(x => x == organisation2.UID))
					result.Add(additionalColumnType2);
				return new OperationResult<List<AdditionalColumnType>>(result);
			});
			ClientManager.RubezhService = mock.Object;

			var employeesViewModel = new EmployeesViewModel();
			employeesViewModel.Initialize(new EmployeeFilter());
			Assert.IsTrue(employeesViewModel.AdditionalColumnTypes.Count == 2);
			employeesViewModel.Initialize(new EmployeeFilter { OrganisationUIDs = new List<Guid> { organisation1.UID } });
			Assert.IsTrue(employeesViewModel.AdditionalColumnTypes.Count == 1);
		}
예제 #4
0
		public static bool Save(AdditionalColumnType AdditionalColumnType, bool isNew)
		{
			var operationResult = ClientManager.RubezhService.SaveAdditionalColumnType(AdditionalColumnType, isNew);
			return Common.ShowErrorIfExists(operationResult);
		}
예제 #5
0
		public static bool Restore(AdditionalColumnType item)
		{
			return Restore(item.UID, item.Name);
		}
예제 #6
0
		public static bool MarkDeleted(AdditionalColumnType item)
		{
			return MarkDeleted(item.UID, item.Name);
		}
예제 #7
0
		public OperationResult<bool> SaveAdditionalColumnType(Guid clientUID, AdditionalColumnType item, bool isNew)
		{
			return SafeOperationCall(clientUID, () => RubezhService.SaveAdditionalColumnType(clientUID, item, isNew), "SaveAdditionalColumnType");
		}
예제 #8
0
		public OperationResult<bool> SaveAdditionalColumnType(AdditionalColumnType item, bool isNew)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.SaveAdditionalColumnType(RubezhServiceFactory.UID, item, isNew);
			}, "SaveAdditionalColumnType");
		}
예제 #9
0
		public OperationResult<bool> SaveAdditionalColumnType(Guid clientUID, AdditionalColumnType item, bool isNew)
		{
			if (isNew)
				AddJournalMessage(JournalEventNameType.Редактирование_дополнительной_колонки, item.Name, item.UID, clientUID, JournalEventDescriptionType.Добавление_дополнительная_колонка, JournalObjectType.AdditionalColumn);
			else
				AddJournalMessage(JournalEventNameType.Редактирование_дополнительной_колонки, item.Name, item.UID, clientUID, JournalEventDescriptionType.Редактирование_дополнительная_колонка, JournalObjectType.AdditionalColumn);
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				return databaseService.AdditionalColumnTypeTranslator.Save(item);
			}
		}