public async Task <bool> Delete(Sample sample) { using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var result = await Task.Run(() => _sampleRepository.Delete(sample)); transactionScope.Complete(); return(result); } }
public void Delete(int id) { Sample result = _respository.Get(id); if (result == null) { throw new ApplicationException("Example does not exists."); } _respository.Delete(result); }
public void SQLSampleRepository_Should_Delete_Sample() { ISampleRepository sut = GetInMemorySampleRepository(); List <SampleModel> samples = sampleInMemoryDb(); sut.Add(samples[0]); Assert.Single(sut.GetAllSamples()); sut.Delete(samples[0].Id); Assert.Empty(sut.GetAllSamples()); }
public bool Remover(int id) { //Regras de negócio aqui using (var scope = new TransactionScope()) { bool efetivado = false; efetivado = SampleRepository.Delete(id); scope.Complete(); return(efetivado); } }
public bool DeleteSample(Sample sample) { try { _sampleRepository.Delete(sample); _sampleRepository.Save(); return(true); } catch (Exception ex) { LogHelper.WriteExceptionLog(ex); return(false); } }
public async Task <IActionResult> DeleteSample(int id, int?page) { var sample = _db.GetSample(id); _db.Delete(id); var samples = _db.GetAllSamples(); var pageNumber = page ?? 1; var sampleList = await samples.Where(m => m.Collection_Title == sample.Collection_Title).ToPagedListAsync(pageNumber, 5); ViewBag.CollectionTitle = sample.Collection_Title; ViewBag.CollectionId = sample.Collection_Id; return(View("Details", sampleList)); }
public bool Delete(int id) { return(_sampleRepository.Delete(id)); }
/// <summary> /// 删除一条示例数据 /// </summary> /// <param name="id">主键值</param> public void DeleteSample(Guid id) { _repository.Delete(id); }