public void Add_ReturnsCorrectView_True() { ClientController controller = new ClientController(); ActionResult addView = controller.Add("Jidenna", 1); Assert.IsInstanceOfType(addView, typeof(RedirectToActionResult)); }
static void Main(string[] args) { var repositoryAssemblyPath = "C:\\Diego\\Projetos Teste\\interceptor-validation\\interceptor-validation\\InterceptorValidation\\Repository\\bin\\Debug\\Repository.dll"; InterceptorValidator.Create(repositoryAssemblyPath); var assembly = Assembly.LoadFile(repositoryAssemblyPath); var nameList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("MC", "WM"), new KeyValuePair <string, string>("MC", "Kekel"), new KeyValuePair <string, string>("MC", "Maha"), new KeyValuePair <string, string>("MC", "Kevinho"), new KeyValuePair <string, string>("MC", "Gustta"), new KeyValuePair <string, string>("MC", "Pikeno"), new KeyValuePair <string, string>("MC", "Menor"), new KeyValuePair <string, string>("MC", "Brinquedo"), new KeyValuePair <string, string>("MC", "Bin Laden") }; var clientController = new ClientController(assembly.CreateInstance("Repository.Repository") as IClientRepository); var random = new Random(); for (int i = 0; i < 20; i++) { var name = nameList[random.Next(9)]; var client = new Client() { Id = random.Next(100), Name = name.Key, SurName = name.Value, BirthDate = DateTime.Now.AddYears(-random.Next(30)) }; clientController.Add(client); } var clients = clientController.GetAll(); foreach (var client in clients) { Console.WriteLine(client); } clientController.Teste(clients.First()); Console.ReadLine(); }
private void ClientAddCommand_Executed(object sender, ExecutedRoutedEventArgs e) { ClientAddWindow wnd = new ClientAddWindow(); wnd.Owner = this; bool result = (bool)wnd.ShowDialog(); if (result) { if (!NetworkUtil.IsPortValid(wnd.Port.Text)) { return; } // Client ClientComponent client = new ClientComponent(); client.Name = wnd.ClientName.Text; client.Download = wnd.DownloadFolder.Text; client.Enabled = true; // Router ServerComponent server = new ServerComponent(); server.Address = wnd.Address.Text; server.Port = int.Parse(wnd.Port.Text); server.Passphrase = wnd.Passphrase.Text; // Group GroupComponent group = new GroupComponent(); group.Path = wnd.GroupPath.Text; GroupImage.Source = group.Image; ClientController.Add(client, server, group); ClientListView.SelectedIndex = ClientController.Count - 1; ClientController.Select(); // Controller MenuController.Update(); BrowseController.Select(); } }
private void AddClientBtn_Click(object sender, RoutedEventArgs e) { InitDataSource(ref clientItems, Mapper.ClientsToClientViewModels, clientController.Get); AddClient addClient = new AddClient(libraryItems); if (addClient.ShowDialog().Value) { string name = addClient.Name.Text; string surname = addClient.Surname.Text; LibraryViewModel model = addClient.SelectedItem; if (model != null) { Library library = libraryController.GetById(model.Id); Client client = new Client(name, surname, library); clientController.Add(client); clientItems.Add(Mapper.ClientToClientViewModel(client)); return; } } }
private void ReadClient(XmlReader reader) { if (reader.IsEmptyElement) { return; } bool loop = true; string name = null; // Components Entity entity = new Entity(); ClientComponent client = new ClientComponent(); ClientOptionsComponent options = new ClientOptionsComponent(); GroupComponent group = new GroupComponent(); ServerComponent server = new ServerComponent(); List <string> paths = new List <string>(); client.Enabled = bool.Parse(reader.GetAttribute(XmlTag.Enabled)); while (loop && reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: { name = reader.Name; switch (name) { case XmlTag.Router: { ReadRouter(reader, ref server); break; } case XmlTag.Options: { ReadOptions(reader, ref options); break; } case XmlTag.Folders: { ReadFolders(reader, ref paths); break; } } break; } case XmlNodeType.Text: { switch (name) { case XmlTag.Id: { entity.Id = reader.Value; break; } case XmlTag.Name: { client.Name = reader.Value; break; } case XmlTag.Download: { client.Download = reader.Value; break; } case XmlTag.Group: { group.Path = reader.Value; break; } } break; } case XmlNodeType.EndElement: { if (XmlTag.Client.Equals(reader.Name)) { loop = false; } break; } } } // Components entity.Add(client); entity.Add(options); entity.Add(group); entity.Add(server); FolderListComponent folderList = new FolderListComponent(); entity.Add(folderList); FileMapComponent fileMap = new FileMapComponent(); entity.Add(fileMap); FolderMapComponent folderMap = new FolderMapComponent(); entity.Add(folderMap); ClientMachineComponent machine = new ClientMachineComponent(); entity.Add <MachineComponent>(machine); SessionComponent session = new SessionComponent(); entity.Add(session); FileComponent file = new FileComponent(); entity.Add(file); SearchListComponent search = new SearchListComponent(SearchController.Dispatcher); entity.Add(search); BrowseComponent browse = new BrowseComponent(); entity.Add(browse); DownloadListComponent download = new DownloadListComponent(DownloadController.Dispatcher); entity.Add(download); UploadListComponent upload = new UploadListComponent(UploadController.Dispatcher); entity.Add(upload); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif ClientController.Add(entity); foreach (string path in paths) { FileComponent shared = new FileComponent(path) { Owner = entity }; folderList.Add(shared); } }
private void dataGridViewClients_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex == -1) //редактрование с второй строки { return; } int taskIndex = dataGridViewClients.Rows[e.RowIndex].Cells["Операция"].ColumnIndex; if (e.ColumnIndex == taskIndex) { string task = dataGridViewClients.Rows[e.RowIndex].Cells[taskIndex].Value.ToString(); if (task == "Удалить") { if (MessageBox.Show("Удалить эту строку?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = (int)dataGridViewClients.CurrentRow.Cells[0].Value; clientController.Delete(id); } } else if (task == "Добавить") { int rowIndex = dataGridViewClients.Rows.Count - 2; DataGridViewRow currentRow = dataGridViewClients.Rows[rowIndex]; Client newClient = GetClientInfo(ref currentRow); if (newClient == null) { return; } if (newClient.Phone.Length > 11) { MessageBox.Show("Номер телефона должен состоять не более чем из 11 цифр."); return; } int currentClientId = clientController.GetClientIdByPhone(newClient.Phone); if (currentClientId != 0) { MessageBox.Show("Введенный номер телефона уже принадлежит другому заказчику."); return; } clientController.Add(newClient); dataGridViewClients.Rows[e.RowIndex].Cells["Операция"].Value = "Удалить"; } else if (task == "Изм.") { int rowIndex = e.RowIndex; DataGridViewRow currentRow = dataGridViewClients.Rows[rowIndex]; Client updatedClient = GetClientInfo(ref currentRow); if (updatedClient == null) { return; } int currentClientId = clientController.GetClientIdByPhone(updatedClient.Phone); if (updatedClient.ID != currentClientId && currentClientId != 0) { MessageBox.Show("Введенный номер телефона уже принадлежит другому заказчику."); return; } clientController.Edit(updatedClient); dataGridViewClients.Rows[rowIndex].Cells["Операция"].Value = "Удалить"; } clientController.GetAllClients(ref dataGridViewClients); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }