public async Task <IActionResult> Delete(string code) { try { var instrumentToDelete = await _repository.GetInstrumentAsync(code); if (instrumentToDelete == null) { return(NotFound("Failed to find the instrument to delete")); } _repository.Delete(instrumentToDelete); if (await _repository.SaveChangesAsync()) { return(Ok()); } else { return(BadRequest("Failed to delete instrument")); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public async Task <IActionResult> Delete(string email) { try { var userDataToDelete = await _repository.GetRegisteredUserAsync(email); if (userDataToDelete == null) { return(NotFound("Failed to find the user to delete")); } _repository.Delete(userDataToDelete); if (await _repository.SaveChangesAsync()) { return(Ok()); } else { return(BadRequest("Failed to delete user")); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public JsonResult Delete(int id) { _instrumentRepository.Delete(id); return(Json(new { InstrumentList = GetInstrumentList(), Success = true, }, JsonRequestBehavior.AllowGet)); }
public void Delete(string id) { var instrument = _instrumentRepository.GetById(id); if (instrument == null) { throw new NotFoundException(Messages.InvalidInstrumentId); } _instrumentRepository.Delete(id); }
/// <summary> /// Deletes and retrieves the deleted item from database /// </summary> /// <param name="id"></param> /// <returns></returns> public Instrument Delete(int id) { if (id != 0) { var instrument = instrumentRepository.Delete(id); instrumentRepository.Commit(); return(instrument); } logger.WriteLog("Failed to delete iteam with id " + id, LogLevel.Warning); return(null); }
/// <summary> /// Deletes and retrieves the deleted item from database /// </summary> /// <param name="id"></param> /// <returns></returns> public Instrument Delete(int id) { if (id != 0) { var instrument = instrumentRepository.Delete(id); instrumentRepository.Commit(); return(instrument); } return(null); }
public void Delete_ValidId_ReturnsResult() { // Arrange var result = fixture.Create <Instrument>(); instrumentRepository.Delete(Arg.Any <int>()).Returns(result); // Act var serviceResult = instrumentService.Delete(1); // Assert Assert.IsNotNull(serviceResult); Assert.AreEqual(serviceResult.Id, result.Id); }
public async Task <IActionResult> DeleteInstrumentById(int id) { var item = await _repo.GetInstrument(id); if (item == null) { return(BadRequest("Impossible d'effacer l'instrument, il n'existe pas")); } _repo.Delete(item); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Impossible d'effacer l'instrument")); }
public async Task <IActionResult> DeleteInstrument(int id) { var item = await _repository.GetInstrument(id); if (item == null) { return(BadRequest("Error: L'instrument n'existe pas.")); } _repository.Delete(item); if (await _repository.SaveAll()) { return(Ok()); } else { return(BadRequest("Impossible d'effacer l'instrument")); } }
public void Delete(Instrument Instrument) { _InstrumentRepository.Delete(Instrument); }