public void AddOrUpdate_GetAll_Delete_TestClass() { Test test = new Test() { Name = "oblect_1" }; testService.AddOrUpdateTest(test); Assert.AreEqual(testService.GetAll().Where(t => t.Name == test.Name).FirstOrDefault().Name, test.Name); foreach (var item in testService.GetAll().ToList()) { testService.Delete(item.Id); } }
public ActionResult DeleteTest(int id, FormCollection collection) { Domain.Entity.Test test = ts.GetById(id); ts.Delete(test); ts.Commit(); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); }
public void Delete_IfEntityToDeleteEqualNull_ReturnsFalse() { // arrange const int id = 1; TestEntity testEntity = null; _currentRepositoryMock.Setup(_ => _.FindById(id)).Returns(testEntity); const bool expectedDeleteResult = false; // act var actualDeleteResult = _sut.Delete(id); // assert _currentRepositoryMock.Verify(_ => _.FindById(id), Times.Once); Assert.Equal(expectedDeleteResult, actualDeleteResult); }
public ActionResult Delete(int id, Test p) { p = cs.GetById(id); cs.Delete(p); cs.Commit(); return(RedirectToAction("ShowTests")); }
public virtual ActionResult Delete() { IList <Guid> ids = SuHuiRequest.GetGuids("ids"); OperationResult or = TestService.Delete(c => ids.Contains(c.Id)); return(this.JsonFormat(or)); }
// DELETE: api/Test/5 public IHttpActionResult Delete(int id) { if (id <= 0) { return(BadRequest("Not a valid id")); } IService <Test> service = new TestService(); service.Delete(id); return(Ok()); }
public string Put(int id) { ResultObject resultt = new ResultObject(); try { var result = testServices.Delete(id); return(JsonConvert.SerializeObject(result)); } catch (Exception e) { resultt.Message = "EXCEPTION: " + e.Message + "Stack: " + e.StackTrace; return(JsonConvert.SerializeObject(resultt)); } }
public ActionResult Delete(int id, FormCollection collection) { try { Test test = new Test(); test = testservice.GetById(id); testservice.Delete(test); testservice.Commit(); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. return(RedirectToAction("Delete", new { id = id, saveChangesError = true })); } return(RedirectToAction("Index")); }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { var selectedItem = (Entities.Test)dgTest.SelectedItem; if (selectedItem != null) { _testService.Delete(selectedItem); MessageBox.Show("Объект успешо удалён!"); RefreshDataGrid(); } else { MessageBox.Show("Выберите объект их таблицы!"); } }
public ActionResult <object> Delete([FromBody] Model.DeleteID deleteID) { Init(); if (!ModelState.IsValid) { Response.StatusCode = 400; return(new string[] { // to "Test does not exist" }); } else { if (deleteID.id == null) { Response.StatusCode = 400; return(new string[] { // to "Test does not exist" }); } StringBuilder sbError = new StringBuilder(""); var isDeleted = _testService.Delete(deleteID.id, ref sbError); if (!isDeleted) { Response.StatusCode = 400; return(new string[] { // to "Test Delete failed" }); } else { Response.StatusCode = 200; return((string)"Test Deleted Successfully"); } } }