Esempio n. 1
0
        public async Task OnRecordEditConfirm()
        {
            #region 進行 Form Validation 檢查驗證作業
            if (LocalEditContext.Validate() == false)
            {
                return;
            }
            #endregion

            #region 檢查資料完整性
            //var checkKindDateResult = CurrentRecord.CheckKindDate();
            //if (string.IsNullOrEmpty(checkKindDateResult) == false)
            //{
            //    MessageBox.Show("400px", "200px", "警告", checkKindDateResult);
            //    return;
            //}
            #endregion

            if (IsShowEditRecord == true)
            {
                if (isNewRecordMode == true)
                {
                    await CurrentService.AddAsync(mapper.Map <Holuser>(CurrentRecord));

                    dataGrid.RefreshGrid();
                }
                else
                {
                    await CurrentService.UpdateAsync(mapper.Map <Holuser>(CurrentRecord));

                    dataGrid.RefreshGrid();
                }
                IsShowEditRecord = false;
            }
        }
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] HoluserDto data)
        {
            APIResult apiResult;
            var       record = await holuserService.GetAsync(id);

            if (record != null)
            {
                Holuser recordTarget = mapper.Map <Holuser>(data);
                recordTarget.HoluserId = id;
                var result       = mapper.Map <HoluserDto>(recordTarget);
                var isSuccessful = await holuserService.UpdateAsync(recordTarget);

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