// Controllers/CheckoutController.cs using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; namespace CheckoutExample.Controllers { [ApiController] [Route("api/[controller]")] public class CheckoutController : ControllerBase { [HttpGet] public IActionResult Get(string products, string coupon) { // Parse products var productQuantities = new Dictionary(); if (!string.IsNullOrEmpty(products)) { foreach (var entry in products.Split(',')) { var parts = entry.Split(':'); if (parts.Length == 2) { if (int.TryParse(parts[1], out int quantity)) { productQuantities.Add(parts[0], quantity); } } } } // Build response var response = new { Products = productQuantities, Coupon = coupon ?? "No coupon applied" }; return Ok(response); } } }
top of page
  • Black Facebook Icon
  • Black Instagram Icon
  • Black Pinterest Icon

    About Us

    Motored Life is the premier destination for high-end motor-assisted bikes and electric power sports equipment. Our journey started in 2012 with a passion for biking, which led to the creation of our YouTube channel dedicated to sharing our experiences and expertise. Now, based in IL, we are thrilled to bring our expertise to the online world with a focus on delivering top-notch products and exceptional customer service.

    About
    bottom of page