public DayTrackViewModel(DayTimeTrack dayTimeTrack, TimeTrackFilter timeTrackFilter, ShortEmployee shortEmployee) { DayTimeTrack = dayTimeTrack; TimeTrackFilter = timeTrackFilter; ShortEmployee = shortEmployee; Update(); }
public TimeTrackDetailsViewModel(DayTimeTrack dayTimeTrack, ShortEmployee shortEmployee) { dayTimeTrack.Calculate(); Title = "Время сотрудника " + shortEmployee.FIO + " в течение дня " + dayTimeTrack.Date.Date.ToString("yyyy-MM-dd"); AddCommand = new RelayCommand(OnAdd, CanAdd); EditCommand = new RelayCommand(OnEdit, CanEdit); RemoveCommand = new RelayCommand(OnRemove, CanRemove); AddFileCommand = new RelayCommand(OnAddFile, CanAddFile); OpenFileCommand = new RelayCommand(OnOpenFile, CanOpenFile); RemoveFileCommand = new RelayCommand(OnRemoveFile, CanRemoveFile); AddCustomPartCommand = new RelayCommand(OnAddCustomPart, CanAddPart); RemovePartCommand = new RelayCommand(OnRemovePart, CanEditRemovePart); EditPartCommand = new RelayCommand(OnEditPart, CanEditRemovePart); DayTimeTrack = dayTimeTrack; ShortEmployee = shortEmployee; DayTimeTrackParts = new ObservableCollection<DayTimeTrackPartViewModel>(); foreach (var timeTrackPart in DayTimeTrack.RealTimeTrackParts) { var employeeTimeTrackPartViewModel = new DayTimeTrackPartViewModel(timeTrackPart); DayTimeTrackParts.Add(employeeTimeTrackPartViewModel); } Documents = new ObservableCollection<DocumentViewModel>(); foreach (var document in dayTimeTrack.Documents) { if (document.EndDateTime > dayTimeTrack.Date.Date) { var documentViewModel = new DocumentViewModel(document); Documents.Add(documentViewModel); } } }
public TimeTrackPartDetailsViewModel(DayTimeTrack dayTimeTrack, ShortEmployee employee, TimeTrackDetailsViewModel parent, Guid? uid = null, TimeSpan? enterTime = null, TimeSpan? exitTime = null) { _DayTimeTrack = dayTimeTrack; _Employee = employee; _Parent = parent; if (uid != null) { UID = uid.Value; EnterTime = enterTime.Value; ExitTime = exitTime.Value; Title = "Редактировать проход"; } else { UID = Guid.NewGuid(); _IsNew = true; Title = "Добавить проход"; } var schedule = ScheduleHelper.GetSingle(employee.ScheduleUID); if (schedule != null) { Zones = new ObservableCollection<TimeTrackZone>(); var gkZones = GKManager.SKDZones.Where(x => schedule.Zones.Any(y => y.ZoneUID == x.UID)); foreach (var zone in gkZones) { Zones.Add(new TimeTrackZone(zone)); } SelectedZone = Zones.FirstOrDefault(); } }
private void InitializeModel(ShortEmployee employee, IEnumerable<ShortEmployeeModel> organisations) { UID = employee.UID; ParentUID = employee.OrganisationUID; OrganisationUID = employee.OrganisationUID; IsOrganisation = false; FIO = employee.FIO; Name = employee.FIO; DepartmentName = employee.DepartmentName; FirstName = employee.FirstName; LastName = employee.LastName; SecondName = employee.SecondName; Phone = employee.Phone; Description = employee.Description; PositionName = employee.PositionName; OrganisationName = employee.OrganisationName; IsDeleted = employee.IsDeleted; RemovalDate = IsDeleted ? employee.RemovalDate.ToString("d MMM yyyy") : ""; Level = 1; IsLeaf = true; IsExpanded = false; if (organisations != null) { var organisation = organisations.FirstOrDefault(o => o.UID == employee.OrganisationUID); if (organisation != null) { organisation.IsLeaf = false; } } }
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); }
public EmployeeSelectionDialogViewModel(ShortEmployee selectedEmployee, EmployeeFilter filter) { Initialize(filter); if (selectedEmployee != null) { SelectedEmployee = Employees.FirstOrDefault(x => x.UID == selectedEmployee.UID); if (SelectedEmployee == null) { Employees.Insert(0, selectedEmployee); SelectedEmployee = selectedEmployee; } } }
public EmployeeCardDetailsViewModel(Organisation organisation, ShortEmployee employee, SKDCard card = null) { _employee = employee; ChangeReaderCommand = new RelayCommand(OnChangeReader); ShowUSBCardReaderCommand = new RelayCommand(OnShowUSBCardReader); Organisation = OrganisationHelper.GetSingle(organisation.UID); if (card == null) { IsNewCard = true; Title = "Создание пропуска"; card = new SKDCard() { EndDate = DateTime.Now.AddYears(1), GKCardType = GKCardType.Employee }; } else { Title = string.Format("Свойства пропуска: {0}", card.Number); } Card = card; CopyProperties(); InitializeGKSchedules(); AccessDoorsSelectationViewModel = new AccessDoorsSelectationViewModel(Organisation, Card.CardDoors, GKSchedules); InitializeAccessTemplates(); var cards = CardHelper.Get(new CardFilter() { DeactivationType = LogicalDeletationType.Deleted }); StopListCards = new ObservableCollection<SKDCard>(); foreach (var item in cards.Where(x => x.IsInStopList)) StopListCards.Add(item); SelectedStopListCard = StopListCards.FirstOrDefault(); CanChangeCardType = _employee.Type == PersonType.Employee && ClientManager.CheckPermission(RubezhAPI.Models.PermissionType.Oper_SKD_Employees_Edit_CardType); GKCardTypes = new ObservableCollection<GKCardType>(Enum.GetValues(typeof(GKCardType)).OfType<GKCardType>()); SelectedGKCardType = Card.GKCardType; AvailableGKControllers = new ObservableCollection<GKControllerViewModel>(); foreach (var device in GKManager.Devices.Where(x => x.DriverType == GKDriverType.GK)) { var controllerViewModel = new GKControllerViewModel(device); controllerViewModel.IsChecked = IsNewCard || (card.GKControllerUIDs != null && card.GKControllerUIDs.Contains(device.UID)); AvailableGKControllers.Add(controllerViewModel); } }
public EscortSelectionViewModel(EmployeeItem department, ShortEmployee shortEmployee, Guid organisationUID) { Title = "Сопровождающий"; var filter = new EmployeeFilter(); if(EmployeeItem.IsNotNullOrEmpty(department)) filter.DepartmentUIDs.Add(department.UID); filter.OrganisationUIDs.Add(organisationUID); Employees = new List<ShortEmployee>(); var employees = EmployeeHelper.Get(filter); if (employees != null) { foreach (var employee in employees) { Employees.Add(employee); } } if (shortEmployee != null) { SelectedEmployee = Employees.FirstOrDefault(x => x.UID == shortEmployee.UID); } }
public static bool SetPosition(ShortEmployee employee, Guid? positionUID) { return SetPosition(employee.UID, positionUID, employee.Name); }
public static bool SetDepartment(ShortEmployee employee, Guid? departmentUID) { return SetDepartment(employee.UID, departmentUID, employee.Name); }
public static bool Restore(ShortEmployee item) { return Restore(item.UID, item.Name, item.Type == PersonType.Employee); }
public static bool MarkDeleted(ShortEmployee item) { return MarkDeleted(item.UID, item.Name, item.Type == PersonType.Employee); }
public void IsShowDeletedPosition() { var organisation = new Organisation(); var department = new ShortDepartment { Name = "DeletedDepartment", OrganisationUID = organisation.UID, IsDeleted = true }; var position = new ShortPosition { Name = "DeletedPosition", OrganisationUID = organisation.UID, IsDeleted = true }; var employee = new Employee { FirstName = "FName", SecondName = "SName", LastName = "LName", OrganisationUID = organisation.UID, DepartmentName = department.Name, DepartmentUID = department.UID, IsDepartmentDeleted = department.IsDeleted, PositionName = position.Name, PositionUID = position.UID, IsPositionDeleted = position.IsDeleted }; var shortEmployee = new ShortEmployee { UID = employee.UID, FirstName = employee.FirstName, SecondName = employee.SecondName, LastName = employee.LastName, OrganisationUID = organisation.UID, DepartmentName = department.Name, IsDepartmentDeleted = department.IsDeleted, PositionName = position.Name, IsPositionDeleted = position.IsDeleted }; ClientManager.CurrentUser.PermissionStrings.Add("Oper_SKD_Employees_Edit"); var mock = new Mock<ISafeRubezhService>(); mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns(() => { return new OperationResult<List<Organisation>>(new List<Organisation> { organisation }); }); mock.Setup(x => x.GetEmployeeList(It.IsAny<EmployeeFilter>())).Returns(() => { return new OperationResult<List<ShortEmployee>>(new List<ShortEmployee> { shortEmployee}); }); mock.Setup(x => x.GetEmployeeDetails(It.IsAny<Guid>())).Returns(() => { return new OperationResult<Employee>(employee); }); mock.Setup(x => x.GetAdditionalColumnTypes(It.IsAny<AdditionalColumnTypeFilter>())).Returns(() => { return new OperationResult<List<AdditionalColumnType>>(); }); mock.Setup(x => x.SaveEmployee(It.IsAny<Employee>(), It.IsAny<bool>())).Returns(() => { return new OperationResult<bool>(true); }); ClientManager.RubezhService = mock.Object; (ServiceFactory.DialogService as MockDialogService).OnShowModal += window => (window as EmployeeDetailsViewModel).SaveCommand.Execute(); var employeesViewModel = new EmployeesViewModel(); employeesViewModel.Initialize(new EmployeeFilter()); employeesViewModel.SelectedItem = employeesViewModel.Organisations.FirstOrDefault().Children.FirstOrDefault(); employeesViewModel.EditCommand.Execute(); Assert.IsTrue(employeesViewModel.SelectedItem.DepartmentName == null || employeesViewModel.SelectedItem.DepartmentName == ""); Assert.IsTrue(employeesViewModel.SelectedItem.PositionName == null || employeesViewModel.SelectedItem.PositionName == ""); }
public static ShortEmployeeModel CreateFromModel(ShortEmployee employee, IEnumerable<ShortEmployeeModel> organisations = null) { var model = new ShortEmployeeModel(); model.InitializeModel(employee, organisations); return model; }