Exemplo n.º 1
0
        /// <summary>
        /// 删除词典数据
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostDeleteDictionaryAsync([FromBody] DeletePermissonViewModel viewModel)
        {
            if (viewModel is null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            if (!TryValidateModel(viewModel))
            {
                return(BadRequest(ModelState));
            }

            var result = await dictionaryService.DeleteDictionaryByIdAsync(viewModel.DictionaryId).ConfigureAwait(false);

            if (result.Succeeded)
            {
                return(new OkResult());
            }

            ModelState.AddModelError(string.Empty, result.ErrorMessage);
            return(BadRequest(ModelState));
        }