예제 #1
0
        public async Task <ActionResult> Delete(int id)
        {
            var entity = await _dataFacade.PostRegions
                         .FirstOrDefaultAsync(e => e.Id == id);

            if (entity == null)
            {
                // 指定的板块不存在
                return(NotFound());
            }

            try
            {
                _dataFacade.RemovePostRegion(entity);
                await _dataFacade.CommitChanges();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "从数据源删除帖子板块时抛出异常:{0}:{1}", ex.GetType(), ex.Message);
                throw;
            }

            return(Ok());
        }