public IActionResult PaymentSuccess() { try { var customer = JsonConvert.DeserializeObject <Models.Customer>(HttpContext.Session.GetString("CustomerSession")); ViewBag.IsLogged = "true"; ViewBag.Name = customer.Name; List <int> ItemIdList = CartItem.GetCartItemIdList(customer.Id, _connection); // Debug.WriteLine(ItemIdList.Count); Debug.WriteLine("iiiiiiiiiiiiiiiiiiii");//int[] x=ItemIdList.GetRange(0,4).ToArray(); for (int i = 0; i < 5; i++) { Debug.WriteLine(i); } Debug.WriteLine("xxooooooooooooooooooooooooooooooooooooooooo"); int[] ItemIdListArray = ItemIdList.GetRange(0, ItemIdList.Count).ToArray(); string arraylist = string.Join(",", ItemIdListArray); Debug.WriteLine(arraylist); Item.ItemSold(arraylist, _connection); CartItem.DeleteMultipleCartItem(customer.Id, _connection); ViewBag.IsLogged = "true"; return(View()); } catch (Exception e) { Debug.WriteLine(e); return(RedirectToAction("Index", "Customer1")); } }