Пример #1
0
        private async Task <IActionResult> CreateOrUpdate(BoxEditDto box)
        {
            var result = new ResultEntity();

            if (ModelState.IsValid)
            {
                if (box.PlaceId > 0)
                {
                    box.SetCreateOrUpdateInfo(CurrentUser.UserId);
                    result = await _boxAppService.AddOrUpdateAsync(box);

                    return(Json(result));
                }

                result.Message = "交换场所不能为空";
                return(Json(result));
            }
            result.Message = ModelState.Values
                             .FirstOrDefault(a => a.ValidationState == ModelValidationState.Invalid)?.Errors.FirstOrDefault()
                             ?.ErrorMessage;

            return(Json(result));
        }