示例#1
0
 public async Task <IActionResult> Edit(PlaceEditDto place)
 {
     if (place.Id <= 0)
     {
         return(Json(new ResultEntity {
             Message = "请求数据有误,修改数据空主键"
         }));
     }
     return(await CreateOrUpdate(place));
 }
示例#2
0
        private async Task <IActionResult> CreateOrUpdate(PlaceEditDto place)
        {
            var result = new ResultEntity();

            if (ModelState.IsValid)
            {
                place.SetCreateOrUpdateInfo(CurrentUser.UserId);
                result = await _placeAppService.AddOrUpdateAsync(place);

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

            return(Json(result));
        }
示例#3
0
        public async Task <ResultEntity> AddOrUpdateAsync(PlaceEditDto place)
        {
            var model  = Mapper.Map <Place>(place);
            var result = await _placeManager.AddOrUpdateAsync(model);

            if (!result.Success)
            {
                return(result);
            }
            await _unitOfWork.CommitAsync();

            if (place.Id > 0)
            {
                await _logManager.LogInfomationAsync(EnumLogType.Audit, LogTitleConstString.PlaceEdit, $"{place.Name}", JsonConvert.SerializeObject(place), place.UpdateBy);
            }
            else
            {
                await _logManager.LogInfomationAsync(EnumLogType.Audit, LogTitleConstString.PlaceAdd, $"{place.Name}", JsonConvert.SerializeObject(place), place.CreateBy);
            }
            return(result);
        }