public void ParameterService_Delete_ExistingParameterEntityPassed_IsRemovedFromCollection() { var p = _parameters.First(x => x.Id == ExistingId); _target.Delete(p); Assert.AreEqual(4, _parameters.Count()); }
// DELETE: api/Parameters/5 public HttpResponseMessage DeleteParameter(int id) { var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Bad Request"); var result = iParameterService.Delete(id); if (result) { message = Request.CreateResponse(HttpStatusCode.OK); } return(message); }
public HttpResponseMessage Delete(int id) { var entity = _parameterService.GetParameterById(id); if (entity == null) { return(PageHelper.toJson(PageHelper.ReturnValue(false, "删除失败!"))); } if (_parameterService.Delete(entity)) { return(PageHelper.toJson(PageHelper.ReturnValue(true, "删除失败!"))); } return(PageHelper.toJson(PageHelper.ReturnValue(false, "删除失败!"))); }
public ActionResult Delete(Guid id) { try { _serviceParameter.Delete(id); return(Ok()); } catch (InvalidTransactionException exception) { ModelState.AddModelError("ErrorMessage", exception.Message); return(BadRequest(ModelState)); } catch (Exception) { ModelState.AddModelError("ErrorMessage", Messages.DangerRecordNotFound); return(BadRequest(ModelState)); } }