Exemplo n.º 1
0
        public async Task <IActionResult> Edit(MenuEditDto menu)
        {
            var result = new ResultEntity();

            if (ModelState.IsValid)
            {
                menu.ParentId = menu.ParentId == 0 ? null : menu.ParentId;
                menu.SetCreateOrUpdateInfo(CurrentUser.UserId);
                result = await _menuAppService.AddOrUpdateAsync(menu);

                return(Json(result));
            }
            result.Message = ModelState.Values
                             .FirstOrDefault(a => a.ValidationState == ModelValidationState.Invalid)?.Errors.FirstOrDefault()
                             ?.ErrorMessage;

            return(Json(result));
        }