public async Task <VerifyRecordResult> UpdateAsync(SystemLogAdapterModel paraObject) { try { SystemLog itemData = Mapper.Map <SystemLog>(paraObject); CleanTrackingHelper.Clean <SystemLog>(context); SystemLog item = await context.SystemLog .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == paraObject.Id); if (item == null) { return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法修改紀錄)); } else { CleanTrackingHelper.Clean <SystemLog>(context); context.Entry(itemData).State = EntityState.Modified; await context.SaveChangesAsync(); CleanTrackingHelper.Clean <SystemLog>(context); return(VerifyRecordResultFactory.Build(true)); } } catch (Exception ex) { Logger.LogError(ex, "修改記錄發生例外異常"); return(VerifyRecordResultFactory.Build(false, "修改記錄發生例外異常", ex)); } }
public async Task OnCommandClicked(CommandClickEventArgs <SystemLogAdapterModel> args) { SystemLogAdapterModel item = args.RowData as SystemLogAdapterModel; if (args.CommandColumn.ButtonOption.IconCss == ButtonIdHelper.ButtonIdRead) { #region 點選 修改紀錄 按鈕 CurrentRecord = item.Clone(); EditRecordDialogTitle = "修改紀錄"; IsShowEditRecord = true; isNewRecordMode = false; #endregion } else if (args.CommandColumn.ButtonOption.IconCss == ButtonIdHelper.ButtonIdDelete) { #region 點選 刪除紀錄 按鈕 CurrentNeedDeleteRecord = item; #region 檢查關聯資料是否存在 var checkedResult = await CurrentService .BeforeDeleteCheckAsync(CurrentNeedDeleteRecord); await Task.Delay(100); if (checkedResult.Success == false) { MessageBox.Show("400px", "200px", "警告", ErrorMessageMappingHelper.Instance.GetErrorMessage(checkedResult.MessageId), MessageBox.HiddenAsync); await Task.Yield(); await thisView.NeedRefreshAsync(); return; } #endregion #region 刪除這筆紀錄 await Task.Yield(); var checkTask = ConfirmMessageBox.ShowAsync("400px", "200px", "警告", "確認要刪除這筆紀錄嗎?", ConfirmMessageBox.HiddenAsync); await thisView.NeedRefreshAsync(); var checkAgain = await checkTask; if (checkAgain == true) { var verifyRecordResult = await CurrentService.DeleteAsync(CurrentNeedDeleteRecord.Id); await TranscationResultHelper.CheckDatabaseResult(MessageBox, verifyRecordResult); dataGrid.RefreshGrid(); } #endregion #endregion } }
public async Task <VerifyRecordResult> BeforeUpdateCheckAsync(SystemLogAdapterModel paraObject) { var searchItem = await context.SystemLog .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == paraObject.Id); if (searchItem == null) { return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.要更新的紀錄_發生同時存取衝突_已經不存在資料庫上)); } return(VerifyRecordResultFactory.Build(true)); }
public async Task <VerifyRecordResult> BeforeDeleteCheckAsync(SystemLogAdapterModel paraObject) { CleanTrackingHelper.Clean <OrderItem>(context); var searchItem = await context.SystemLog .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == paraObject.Id); if (searchItem == null) { return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄_要刪除的紀錄已經不存在資料庫上)); } return(VerifyRecordResultFactory.Build(true)); }
public async Task <SystemLogAdapterModel> GetAsync(int id) { SystemLog item = await context.SystemLog .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == id); SystemLogAdapterModel result = Mapper.Map <SystemLogAdapterModel>(item); await OhterDependencyData(result); return(result); }
public void ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) { if (args.Item.Id == ButtonIdHelper.ButtonIdAdd) { CurrentRecord = new SystemLogAdapterModel(); #region 針對新增的紀錄所要做的初始值設定商業邏輯 #endregion EditRecordDialogTitle = "新增紀錄"; isNewRecordMode = true; IsShowEditRecord = true; } else if (args.Item.Id == ButtonIdHelper.ButtonIdRefresh) { dataGrid.RefreshGrid(); } }
public async Task <VerifyRecordResult> AddAsync(SystemLogAdapterModel paraObject) { try { SystemLog itemParameter = Mapper.Map <SystemLog>(paraObject); CleanTrackingHelper.Clean <SystemLog>(context); await context.SystemLog .AddAsync(itemParameter); await context.SaveChangesAsync(); CleanTrackingHelper.Clean <SystemLog>(context); return(VerifyRecordResultFactory.Build(true)); } catch (Exception ex) { Logger.LogError(ex, "新增記錄發生例外異常"); return(VerifyRecordResultFactory.Build(false, "新增記錄發生例外異常", ex)); } }
public async Task OnCommandClicked(CommandClickEventArgs <SystemLogAdapterModel> args) { SystemLogAdapterModel item = args.RowData as SystemLogAdapterModel; if (args.CommandColumn.ButtonOption.IconCss == ButtonIdHelper.ButtonIdRead) { #region 點選 修改紀錄 按鈕 CurrentRecord = item.Clone(); EditRecordDialogTitle = "修改紀錄"; IsShowEditRecord = true; isNewRecordMode = false; #endregion } else if (args.CommandColumn.ButtonOption.IconCss == ButtonIdHelper.ButtonIdDelete) { #region 點選 刪除紀錄 按鈕 CurrentNeedDeleteRecord = item; #region 檢查關聯資料是否存在 var checkedResult = await CurrentService .BeforeDeleteCheckAsync(CurrentNeedDeleteRecord); await Task.Delay(100); if (checkedResult.Success == false) { MessageBox.Show("400px", "200px", "警告", ErrorMessageMappingHelper.Instance.GetErrorMessage(checkedResult.MessageId)); await Task.Yield(); thisView.NeedRefresh(); return; } #endregion ConfirmMessageBox.Show("400px", "200px", "警告", "確認要刪除這筆紀錄嗎?"); #endregion } }
public async Task LogAsync(SystemLogAdapterModel systemLogAdapterModel, Action action = null) { action?.Invoke(); await SystemLogService.AddAsync(systemLogAdapterModel); }
Task OhterDependencyData(SystemLogAdapterModel data) { return(Task.FromResult(0)); }
public async Task <VerifyRecordResult> BeforeAddCheckAsync(SystemLogAdapterModel paraObject) { await Task.Yield(); return(VerifyRecordResultFactory.Build(true)); }