public void C_Delete() { RestController api = new RestController(GetConnectionString()); ApplicationResultRecords result1 = api.Get(); ApplicationResultBase result2 = api.Delete(result1.Records[0].ID); Assert.IsTrue(result2.Success); ApplicationResultBase result3 = api.Delete(result1.Records[1].ID); Assert.IsTrue(result3.Success); ApplicationResultRecords result4 = api.Get(); Assert.IsTrue(result4.Success); Assert.IsNull(result4.Records); }
public ApplicationResultBase Delete(long id) { ApplicationResultBase result = null; try { string error = _Storage.Delete(id); if (string.IsNullOrEmpty(error)) { result = new ApplicationResultSuccess(); } else { result = new ApplicationResultFailure(error); } } catch (Exception ex) { result = new ApplicationResultFailure("Fail to erase record!", ex); } return(result); }