Exemple #1
0
        public async Task <ApiResult <bool> > Update(PaymentUpdateRequest request)
        {
            try
            {
                var payment = await _context.PaymentMethods.FindAsync(request.id);

                if (payment != null)
                {
                    payment.description = request.description;
                    payment.isActive    = request.isActive;
                    request.name        = request.name;
                    payment.update_at   = DateTime.Now;

                    await _context.SaveChangesAsync();

                    return(new ApiSuccessResult <bool>());
                }
                else
                {
                    return(new ApiErrorResult <bool>("Không tìm thấy phương thức này"));
                }
            }
            catch
            {
                return(new ApiErrorResult <bool>("Cập nhật thất bại"));
            }
        }
        public PaymentUpdateResponse PaymentUpdate(PaymentUpdateRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            return(SendPostRequest <PaymentUpdateRequest, PaymentUpdateResponse>(request, "PaymentUpdate"));
        }
Exemple #3
0
        public async Task <IActionResult> Update([FromBody] PaymentUpdateRequest request)
        {
            var result = await _paymentService.Update(request);

            if (!result.IsSuccess)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Exemple #4
0
        public async Task <IActionResult> Update(PaymentUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(View(request));
            }
            var result = await _paymentApiClient.UpdatePayment(request);

            if (result.IsSuccess)
            {
                TempData["result"] = "Cập nhật phương thức thành công";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", result.Message);
            return(View(request));
        }
Exemple #5
0
        public async Task <Response <PaymentResponse> > Update(PaymentUpdateRequest request)
        {
            var result = await _uow.Payments.FindAsync(new Guid(request.Id));

            if (result == null)
            {
                return(new Response <PaymentResponse>(ResponseStatus.NotFound, null, ResponseMessagesConstans.NotFound));
            }

            result.IsActive    = request.IsActive;
            result.Name        = request.Name;
            result.Description = request.Description;
            result.Image       = request.Image;
            result.TotalPrice  = new Price(request.PriceWithoutVat);
            result             = await _uow.Payments.FindAndReplaceAsync(new Guid(request.Id), result);

            return(new Response <PaymentResponse>(ResponseStatus.Ok, _mapService.MapPayment(result)));
        }
        public PaymentUpdateResponse PaymentUpdate(string merchantTransactionID, PaymentStatusCode paymentStatusCode)
        {
            if (merchantTransactionID == null)
            {
                throw new ArgumentNullException("merchantTransactionID");
            }

            if (paymentStatusCode == null)
            {
                throw new ArgumentNullException("paymentStatusCode");
            }

            var request = new PaymentUpdateRequest
            {
                MerchantTransactionID = merchantTransactionID,
                PaymentStatusCode     = paymentStatusCode
            };

            return(PaymentUpdate(request));
        }
Exemple #7
0
        public async Task <ApiResult <bool> > UpdatePayment(PaymentUpdateRequest request)
        {
            var client = _httpClientFactory.CreateClient();

            client.BaseAddress = new Uri(_configuration["BaseAddress"]);

            var json        = JsonConvert.SerializeObject(request);
            var httpContent = new StringContent(json, Encoding.UTF8, "application/json");

            var respone = await client.PutAsync($"/api/payment", httpContent);

            var result = await respone.Content.ReadAsStringAsync();

            if (respone.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <ApiSuccessResult <bool> >(result));
            }
            else
            {
                return(JsonConvert.DeserializeObject <ApiErrorResult <bool> >(result));
            }
        }
Exemple #8
0
        public async Task <IActionResult> Update(int id)
        {
            var result = await _paymentApiClient.GetById(id);

            if (!result.IsSuccess || result.ResultObject == null)
            {
                TempData["error"] = result.Message;
                return(RedirectToAction("Index"));
            }
            var updateRequest = new PaymentUpdateRequest()
            {
                id          = id,
                isActive    = result.ResultObject.isActive,
                name        = result.ResultObject.name,
                description = result.ResultObject.description,
            };

            if (TempData["result"] != null)
            {
                ViewBag.SuccessMsg = TempData["result"];
            }
            return(View(updateRequest));
        }
Exemple #9
0
        public async Task CanUpdatePayment()
        {
            // Given: We create a payment with only the required parameters
            PaymentRequest paymentRequest = new PaymentRequest()
            {
                Amount      = new Amount(Currency.EUR, "100.00"),
                Description = "Description",
                RedirectUrl = this.DefaultRedirectUrl
            };
            PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest);

            // When: We update this payment
            PaymentUpdateRequest paymentUpdateRequest = new PaymentUpdateRequest()
            {
                Description = "Updated description",
                Metadata    = "My metadata"
            };
            PaymentResponse updatedPayment = await this._paymentClient.UpdatePaymentAsync(result.Id, paymentUpdateRequest);

            // Then: Make sure the payment is updated
            Assert.AreEqual(paymentUpdateRequest.Description, updatedPayment.Description);
            Assert.AreEqual(paymentUpdateRequest.Metadata, updatedPayment.Metadata);
        }
Exemple #10
0
        public async Task <IHttpActionResult> Put([FromBody] PaymentUpdateRequest request)
        {
            var response = await _paymentService.Update(request);

            return(new CreateResult(response));
        }
Exemple #11
0
 public async Task <PaymentResponse> UpdatePaymentAsync(string paymentId, PaymentUpdateRequest paymentUpdateRequest)
 {
     return(await this.PatchAsync <PaymentResponse>($"payments/{paymentId}", paymentUpdateRequest).ConfigureAwait(false));
 }
 public async Task <IList <HSPayment> > SavePayments(string orderID, [FromBody] PaymentUpdateRequest request)
 {
     return(await _command.SavePayments(orderID, request.Payments, UserContext.AccessToken));
 }