public void Remove_InvalidId_ReturnsNotFoundResponse() { // Arrange var id = -1; // Act var badResponse = _controller.Delete(id); // Assert Assert.IsType <NotFoundObjectResult>(badResponse); }
private void SupprimerLigne(object sender, EventArgs e) { try { if (_currentDeclaration == null) { return; } if (_currentDeclaration.Cloturer) { throw new ApplicationException("Opération invalide! [Déclaration est validé]"); } List <LigneView> listLigne = new List <LigneView>(); foreach (var row in viewLigne.GetSelectedRows()) { listLigne.Add(viewLigne.GetRow(row) as LigneView); } var result = XtraMessageBox.Show( string.Format("Voulez vous supprimer {0} Ligne(s) ?", listLigne.Count), Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result != DialogResult.Yes) { return; } foreach (var ligne in listLigne) { if (ligne == null) { continue; } _controller.Delete(ligne); var indexOld = _listLignes.IndexOf(ligne); _listLignes.Remove(ligne); if (indexOld < 0) { return; } } //viewLigne.FocusedRowHandle = indexOld - 1; } catch (Exception ex) { XtraMessageBox.Show(ex.Message, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SupprimerLigne(object sender, EventArgs e) { try { if (_currentDeclaration == null) { return; } if (_currentDeclaration.IsCloture) { throw new ApplicationException("Opération invalide! [Déclaration est validé]"); } var ligne = viewLigne.GetFocusedRow() as LigneView; if (ligne == null) { return; } var result = XtraMessageBox.Show( string.Format("Voulez vous supprimer bon commande N°[{0}]?", ligne.NumeroBonCommande), Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result != DialogResult.Yes) { return; } _controller.Delete(ligne); var indexOld = _listLignes.IndexOf(ligne); _listLignes.Remove(ligne); if (indexOld < 0) { return; } viewLigne.FocusedRowHandle = indexOld - 1; } catch (Exception ex) { XtraMessageBox.Show(ex.Message, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }