Exemplo n.º 1
0
        public async Task DeleteAsync(Guid id)
        {
            var entity = await _demoRepository.GetByKeyAsync(id);

            if (entity == null)
            {
                throw new NotFoundEntityException("示例");
            }
            await _demoRepository.DeleteAsync(entity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 删除Demo
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task <OperationResult <bool> > DeleteDemoAsync(string Id)
        {
            using (var tran = _context.Database.BeginTransaction())//开始事务
            {
                try
                {
                    var result = new OperationResult <bool>();
                    var demo   = await _demoRepository.FindAsync(Id);

                    if (demo != null)
                    {
                        result.data = await _demoRepository.DeleteAsync(demo);

                        tran.Commit();//提交事务
                    }
                    return(result);
                }
                catch (Exception ex)
                {
                    tran.Rollback();//回滚事务
                    throw ex;
                }
            }
        }
 /// <summary>
 /// 根据根据主键删除
 /// </summary>
 /// <param name="deleteSingleModel"></param>
 /// <returns></returns>
 public async Task <HttpResponseResultModel <bool> > DeleteAsync(DeleteSingleModel <long> deleteSingleModel)
 {
     return(await repository.DeleteAsync(deleteSingleModel).ConfigureAwait(false));
 }
 public async Task <int> Delete(User user)
 {
     return(await _demoRepository.DeleteAsync(user.Id.ToString()));
 }