public void DBSalespersonTest_Delete_Fail_ID() { DBSalesperson dBSalesperson = new DBSalesperson(); Salesperson person = new Salesperson() { Name = "Definitely A", LastName = "Not Existing Person", Id = -1 }; dBSalesperson.Delete(person.Id); }
public void DBSalespersonTest_Persist_Delete() { DBSalesperson dBSalesperson = new DBSalesperson(); Salesperson person = new Salesperson() { Name = "Test", LastName = "Object" }; dBSalesperson.Persist(person); Salesperson salesman = dBSalesperson.GetAll().SingleOrDefault(x => { return(x.Name.Equals("Test") && x.LastName.Equals("Object")); }); dBSalesperson.Delete(salesman.Id); }
// DELETE: api/Salesperson/5 public Salesperson Delete(int id) { var faulted = new Salesperson(); faulted.IsFaulted = false; try { db.Delete(id); return(faulted); } catch (DatabaseLink.DataLayerArgumentException e) { faulted.IsFaulted = true; faulted.DataLayerArgumentException = e.Message; } catch (DatabaseLink.DataLayerException e) { faulted.IsFaulted = true; faulted.DataLayerException = e.Message; } return(faulted); }