コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public void Delete(int id)
        {
            Sample result = _respository.Get(id);

            if (result == null)
            {
                throw new ApplicationException("Example does not exists.");
            }
            _respository.Delete(result);
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
ファイル: SampleService.cs プロジェクト: atifrehman/NEC
        public bool DeleteSample(Sample sample)
        {
            try
            {
                _sampleRepository.Delete(sample);
                _sampleRepository.Save();

                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.WriteExceptionLog(ex);
                return(false);
            }
        }
コード例 #6
0
        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));
        }
コード例 #7
0
 public bool Delete(int id)
 {
     return(_sampleRepository.Delete(id));
 }
コード例 #8
0
 /// <summary>
 /// 删除一条示例数据
 /// </summary>
 /// <param name="id">主键值</param>
 public void DeleteSample(Guid id)
 {
     _repository.Delete(id);
 }