public ActionResult GetAllUserPayment(string userId) { List <PaymentMethods> userPaymentMethods = _paymentMethodService.GetAllUserPaymentMethod(userId); List <PaymentMethodViewModel> paymentMethodVMs = new List <PaymentMethodViewModel>(); PaymentMethodViewModel paymentMethodVM; foreach (var upm in userPaymentMethods) { paymentMethodVM = new PaymentMethodViewModel() { Id = upm.Id, CreatedTime = upm.CreatedTime, InUsed = upm.InUsed, IsDefault = upm.IsDefault, PaymentType = upm.PaymentType, UserId = upm.UserId, }; if (paymentMethodVM.PaymentType == PaymentType.Wallet) { paymentMethodVM.Wallets = upm.Wallets; } paymentMethodVMs.Add(paymentMethodVM); } return(new JsonResult(paymentMethodVMs) { StatusCode = StatusCodes.Status200OK }); }