コード例 #1
0
        public async Task <ActionResult <WithdrawalSetupRegRespObj> > AddUpdateWithdrawalSetupAsync([FromBody] AddUpdateWithdrawalSetupObj model)
        {
            try
            {
                var user = await _identityServer.UserDataAsync();

                deposit_withdrawalsetup item = null;
                if (model.WithdrawalSetupId > 0)
                {
                    item = await _repo.GetWithdrawalSetupByIdAsync(model.WithdrawalSetupId);

                    if (item == null)
                    {
                        return new WithdrawalSetupRegRespObj
                               {
                                   Status = new APIResponseStatus {
                                       IsSuccessful = false, Message = new APIResponseMessage {
                                           FriendlyMessage = "Item does not Exist"
                                       }
                                   }
                               }
                    }
                    ;
                }

                var domainObj = new deposit_withdrawalsetup();

                domainObj.WithdrawalSetupId    = model.WithdrawalSetupId > 0 ? model.WithdrawalSetupId : 0;
                domainObj.Structure            = model.Structure;
                domainObj.Product              = model.Product;
                domainObj.PresetChart          = model.PresetChart;
                domainObj.AccountType          = model.AccountType;
                domainObj.DailyWithdrawalLimit = model.DailyWithdrawalLimit;
                domainObj.WithdrawalCharges    = model.WithdrawalCharges;
                domainObj.Charge     = model.Charge;
                domainObj.Amount     = model.Amount;
                domainObj.ChargeType = model.ChargeType;
                domainObj.Active     = true;
                domainObj.CreatedOn  = DateTime.Today;
                domainObj.CreatedBy  = user.UserName;
                domainObj.Deleted    = false;
                domainObj.UpdatedOn  = model.WithdrawalSetupId > 0 ? DateTime.Today : DateTime.Today;
                domainObj.UpdatedBy  = user.UserName;

                var isDone = await _repo.AddUpdateWithdrawalSetupAsync(domainObj);

                return(new WithdrawalSetupRegRespObj
                {
                    WithdrawalSetupId = domainObj.WithdrawalSetupId,
                    Status = new APIResponseStatus {
                        IsSuccessful = isDone ? true : false, Message = new APIResponseMessage {
                            FriendlyMessage = isDone ? "successful" : "Unsuccessful"
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                var errorCode = ErrorID.Generate(5);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new WithdrawalSetupRegRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage {
                            FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                        }
                    }
                });
            }
        }