Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
        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());
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 5
0
        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));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 删除一条示例数据
 /// </summary>
 /// <param name="id">主键值</param>
 public void DeleteSample(Guid id)
 {
     _repository.Delete(id);
 }