public async Task <IActionResult> Edit(PlaceEditDto place) { if (place.Id <= 0) { return(Json(new ResultEntity { Message = "请求数据有误,修改数据空主键" })); } return(await CreateOrUpdate(place)); }
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)); }
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); }