예제 #1
0
        public async Task <ApiResponse> Handle(AddEditPensionDebitAccountCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();
            PensionDebitAccountMaster pensionDebitAccount;

            try
            {
                pensionDebitAccount = await _dbContext.PensionDebitAccountMaster.FirstOrDefaultAsync(x => x.IsDeleted == false);

                if (pensionDebitAccount == null)
                {
                    pensionDebitAccount = new PensionDebitAccountMaster();
                    pensionDebitAccount.ChartOfAccountNewId = request.accountId;
                    pensionDebitAccount.CreatedDate         = request.CreatedDate;
                    pensionDebitAccount.CreatedById         = request.CreatedById;
                    pensionDebitAccount.IsDeleted           = false;

                    await _dbContext.PensionDebitAccountMaster.AddAsync(pensionDebitAccount);

                    await _dbContext.SaveChangesAsync();
                }
                else
                {
                    pensionDebitAccount.ModifiedById        = request.ModifiedById;
                    pensionDebitAccount.ModifiedDate        = request.ModifiedDate;
                    pensionDebitAccount.ChartOfAccountNewId = request.accountId;

                    await _dbContext.SaveChangesAsync();
                }

                response.StatusCode = StaticResource.successStatusCode;
                response.Message    = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }

            return(response);
        }
        public async Task <ApiResponse> Handle(GetPensionDebitAccountQuery request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                PensionDebitAccountMaster pensionDebitAccount = await _dbContext.PensionDebitAccountMaster.FirstOrDefaultAsync(x => x.IsDeleted == false);

                if (pensionDebitAccount != null)
                {
                    response.data.PensionDebitAccountId = pensionDebitAccount.ChartOfAccountNewId;
                }

                response.StatusCode = StaticResource.successStatusCode;
                response.Message    = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }