public AccessTableVM() { //SetRightCommand = new Commands.DelegateCommand(SetRight); BackCommand = new Commands.DelegateCommand(o => NavigationService.Navigate(NavigationService.ExplorerPage)); AddRoleCommand = new Commands.DelegateCommand(o => { OsService.GetOS().RMon.AddRole(RoleName); RoleName = string.Empty; OnPropertyChanged("Roles"); }); RemoveRoleCommand = new Commands.DelegateCommand(o => { OsService.GetOS().RMon.RemoveRole(SelectedRole); OnPropertyChanged("Roles"); OnPropertyChanged("UsersRoles"); }); AddRoleToUserCommand = new Commands.DelegateCommand(o => { OsService.GetOS().RMon.AddRoleToUser(SelectedUser, SelectedUserRole); OnPropertyChanged("UsersRoles"); }); RemoveRoleFromUserCommand = new Commands.DelegateCommand(o => { OsService.GetOS().RMon.RemoveRoleFromUser(SelectedUser, SelectedUserRole); OnPropertyChanged("UsersRoles"); }); }
public ExplorerVM() { os = OsService.GetOS(); OpenFileCommand = new Commands.DelegateCommand(OpenFile); CreateFileCommand = new Commands.DelegateCommand(CreateFile); RenameFileCommand = new Commands.DelegateCommand(RenameFile); RemoveFileCommand = new Commands.DelegateCommand(RemoveFile); NavigateCommand = new Commands.DelegateCommand(Navigate); }
public void DeleteOrder() { var orderRepository = new Mock <IOrderRepository>(); orderRepository.Setup(x => x.Delete(It.IsAny <Func <Order, bool> >())).Returns(true); var orderService = new OsService(orderRepository.Object); var result = orderService.Delete(x => x.Id == Guid.NewGuid()); Assert.True(result); }
public void login(object o) { try { OsService.GetOS().Login(Name, Password); Name = Password = string.Empty; NavigationService.Navigate(NavigationService.SelectRolePage); } catch (OS.UserMgrException e) { MessageBox.Show(e.Message); } }
public void registrate(object o) { try { OsService.GetOS().Umgr.Registrate(Name, Password); OsService.GetOS().Login(Name, Password); Name = Password = string.Empty; //NavigationService.Navigate(NavigationService.ExplorerPage); } catch (OS.UserMgrException e) { MessageBox.Show(e.Message); } }
private void AccessMatrix_TextBox_TextChanged(object sender, TextChangedEventArgs e) { try { TextBox tb = (TextBox)sender; OS.UserRole role = (OS.UserRole)((object[])tb.Tag)[0]; OS.FileObject file = (OS.FileObject)((object[])tb.Tag)[1]; var rights = OsService.GetOS().RMon.ParseRights(tb.Text); OsService.GetOS().RMon.SetRights(role, rights, file); } catch (OS.OsException ex) { MessageBox.Show(ex.Message); } }
public SelectRoleVM() { SelectRoleCommand = new Commands.DelegateCommand(o => { var os = OsService.GetOS(); os.SelectRole(SelectedUserRole); if (os.Sessions.HasSession(os.SessionId)) { var res = MessageBox.Show("Продолжить существующую сессию?", "Сессия", MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { NavigationService.Navigate(NavigationService.ExplorerPage); return; } } os.Sessions.StartSession(os.SessionId); NavigationService.Navigate(NavigationService.ExplorerPage); }); }
public void GetListOfOrders() { var orders = new List <Order> { new Order { CustomerId = Guid.NewGuid(), EmployeeId = Guid.NewGuid(), Date = DateTime.Now, Start = DateTime.Now.Date.TimeOfDay, Finish = DateTime.Now.Date.AddHours(8).TimeOfDay, Description = "teste teste teste 1" }, new Order { CustomerId = Guid.NewGuid(), EmployeeId = Guid.NewGuid(), Date = DateTime.Now, Start = DateTime.Now.Date.TimeOfDay, Finish = DateTime.Now.Date.AddHours(8).TimeOfDay, Description = "teste teste teste 2" }, new Order { CustomerId = Guid.NewGuid(), EmployeeId = Guid.NewGuid(), Date = DateTime.Now, Start = DateTime.Now.Date.TimeOfDay, Finish = DateTime.Now.Date.AddHours(8).TimeOfDay, Description = "teste teste teste 3" } }; var orderRepositoryMock = new Mock <IOrderRepository>(); orderRepositoryMock.Setup(x => x.Search(It.IsAny <OrderFilter>())).Returns(orders); var orderService = new OsService(orderRepositoryMock.Object); var result = orderService.Search(new OrderFilter()); Assert.NotNull(result); Assert.Equal(3, result.Count()); }
public void CreateOrderWithStartHigherThanFinish() { var order = new Order { CustomerId = Guid.NewGuid(), EmployeeId = Guid.NewGuid(), Date = DateTime.Now, Start = DateTime.Now.Date.AddHours(8).TimeOfDay, Finish = DateTime.Now.Date.TimeOfDay, Description = "teste teste teste" }; var orderRepositoryMock = new Mock <IOrderRepository>(); orderRepositoryMock.Setup(x => x.Create(It.IsAny <Order>())).Returns(order); var orderService = new OsService(orderRepositoryMock.Object); var exception = Assert.Throws <ArgumentException>(() => orderService.Create(order)); Assert.Equal("Hora de início não pode ser maior ou igual a hora de término da Ordem de Serviço.", exception.Message); }
public void CreateOrderWithoutCustomer() { var order = new Order { CustomerId = Guid.Empty, EmployeeId = Guid.NewGuid(), Date = DateTime.Now, Start = DateTime.Now.Date.TimeOfDay, Finish = DateTime.Now.Date.AddHours(8).TimeOfDay, Description = "teste teste teste" }; var orderRepositoryMock = new Mock <IOrderRepository>(); orderRepositoryMock.Setup(x => x.Create(It.IsAny <Order>())).Returns(order); var orderService = new OsService(orderRepositoryMock.Object); var exception = Assert.Throws <ArgumentException>(() => orderService.Create(order)); Assert.Equal("Não é possível salvar uma Ordem de Serviço sem cliente.", exception.Message); }
public void GetOrderById() { var order = new Order { CustomerId = Guid.NewGuid(), EmployeeId = Guid.NewGuid(), Date = DateTime.Now, Start = DateTime.Now.Date.TimeOfDay, Finish = DateTime.Now.Date.AddHours(8).TimeOfDay, Description = "teste teste teste" }; var orderRepositoryMock = new Mock <IOrderRepository>(); orderRepositoryMock.Setup(x => x.Get(It.IsAny <Func <Order, bool> >())).Returns(order); var orderService = new OsService(orderRepositoryMock.Object); var result = orderService.Get(x => x.Id == Guid.NewGuid()); Assert.NotNull(result); }
public bool InsertOrUpdate(OsService OsService) { return(_epr.InsertOrUpdate(OsService)); }
public bool Save(OsService OsService) { _OsServiceApp.InsertOrUpdate(OsService); return(_connection.Save()); }
public OSController(OsService osService, PessoaService pessoaService, StatusService statusService) { _osService = osService; _pessoaService = pessoaService; _statusService = statusService; }
void UpdateAccessMatrix() { var os = OsService.GetOS(); Grid gMatrix = new Grid(); gMatrix.VerticalAlignment = VerticalAlignment.Top; gMatrix.HorizontalAlignment = HorizontalAlignment.Left; for (int i = 0; i < os.RMon.Roles.Count + 1; i++) { gMatrix.RowDefinitions.Add(new RowDefinition()); } for (int i = 0; i < os.Fs.Files.Count + 1; i++) { gMatrix.ColumnDefinitions.Add(new ColumnDefinition()); } for (int i = 0; i < os.Fs.Files.Count; i++) { var tbHeader = new TextBlock(); tbHeader.Text = os.Fs.Files[i].ToString(); tbHeader.VerticalAlignment = VerticalAlignment.Center; tbHeader.TextAlignment = TextAlignment.Center; tbHeader.TextWrapping = TextWrapping.Wrap; tbHeader.Margin = new Thickness(3); gMatrix.Children.Add(tbHeader); Grid.SetRow(tbHeader, 0); Grid.SetColumn(tbHeader, i + 1); } int irole = 0; foreach (var role in os.RMon.Roles.Values) { var tbHeader = new TextBlock(); tbHeader.Text = role.ToString(); tbHeader.VerticalAlignment = VerticalAlignment.Center; tbHeader.TextAlignment = TextAlignment.Center; tbHeader.TextWrapping = TextWrapping.Wrap; tbHeader.Margin = new Thickness(3); gMatrix.Children.Add(tbHeader); Grid.SetRow(tbHeader, irole + 1); Grid.SetColumn(tbHeader, 0); irole += 1; } irole = 0; foreach (var role in os.RMon.Roles.Values) { for (int i = 0; i < os.Fs.Files.Count; i++) { var tbRights = new TextBox(); tbRights.Tag = new object[] { role, os.Fs.Files[i] }; var rights = os.RMon.Get(role, os.Fs.Files[i]); tbRights.Text = os.RMon.RightsToString(rights); tbRights.TextChanged += AccessMatrix_TextBox_TextChanged; gMatrix.Children.Add(tbRights); Grid.SetRow(tbRights, irole + 1); Grid.SetColumn(tbRights, i + 1); } irole += 1; } tiAccessMatrix.Content = gMatrix; //gAccessMatrix = gMatrix; }