示例#1
0
        public async Task <ResponseModel <Payment> > NewPayment(Payment payment)
        {
            ResponseModel <Payment> response = new ResponseModel <Payment>()
            {
                ResponseData = new List <Payment>(),
                Errors       = new List <string>()
            };

            if (payment == null)
            {
                response.ResponseCode    = ReturnCodesConstant.R08;
                response.ResponseMessage = ReturnCodesConstant.R08Message;
                response.Errors.Add("No payment record provided.");
                return(response);
            }
            ;

            sessionId = GetSessionId();

            payment.CartId = sessionId;



            if (await _dbRepo.AddPayment(payment))
            {
                response.ResponseCode    = ReturnCodesConstant.R00;
                response.ResponseMessage = ReturnCodesConstant.R00Message;
                response.ResponseData.Add(payment);
                return(response);
            }
            else
            {
                response.ResponseCode    = ReturnCodesConstant.R05;
                response.ResponseMessage = ReturnCodesConstant.R05Message;
                response.Errors.Add(ReturnCodesConstant.CREATE_NEW_PAYMENT_FAILED);
                return(response);
            }
        }