Exemplo n.º 1
0
 public async Task <IActionResult> Create(BoxEditDto box)
 {
     if (box.Id > 0)
     {
         return(Json(new ResultEntity {
             Message = "请求数据有误,新增数据非0主键"
         }));
     }
     return(await CreateOrUpdate(box));
 }
Exemplo n.º 2
0
        public async Task <ResultEntity> AddOrUpdateAsync(BoxEditDto editDto)
        {
            var result = await _boxManager.AddOrUpdateAsync(Mapper.Map <Box>(editDto));

            if (result.Success)
            {
                await _unitOfWork.CommitAsync();
            }
            return(result);
        }
Exemplo n.º 3
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));
        }