public async Task RemoveThisRecord(bool NeedDelete)
        {
            if (NeedDelete == true)
            {
                await CurrentService.DeleteAsync(CurrentNeedDeleteRecord.Id);

                dataGrid.RefreshGrid();
            }
            ConfirmMessageBox.Hidden();
        }
Esempio n. 2
0
        public async Task <IActionResult> Delete([FromRoute] int id)
        {
            APIResult apiResult;
            var       record = await LeaveFormService.GetAsync(id);

            var result = mapper.Map <LeaveFormDto>(record);

            if (record != null)
            {
                #region 刪除記錄前的紀錄完整性檢查
                VerifyRecordResult verify = await LeaveFormService.BeforeDeleteCheckAsync(record);

                if (verify.Success == false)
                {
                    apiResult = APIResultFactory.Build(false, StatusCodes.Status200OK,
                                                       ErrorMessageMappingHelper.Instance.GetErrorMessage(verify.MessageId),
                                                       payload: result);
                    return(Ok(apiResult));
                }
                #endregion

                var verifyRecordResult = await LeaveFormService.DeleteAsync(id);

                if (verifyRecordResult.Success)
                {
                    apiResult = APIResultFactory.Build(true, StatusCodes.Status202Accepted,
                                                       ErrorMessageEnum.None, payload: null);
                }
                else
                {
                    apiResult = APIResultFactory.Build(false, StatusCodes.Status200OK,
                                                       ErrorMessageEnum.無法刪除紀錄, payload: result);
                }
            }
            else
            {
                apiResult = APIResultFactory.Build(false, StatusCodes.Status200OK,
                                                   ErrorMessageEnum.沒有任何符合資料存在, payload: result);
            }
            return(Ok(apiResult));
        }