this is my action to add new address on a step form , step form have 4 part that have a main Id for form , I want in the second tab add to new address and if method was success return to my view, but return to second tab , not first of view
these are my methods:
[HttpPost]
public async Task<IActionResult> AddNewAddress(CartAddressViewModel model, int clientId)
{
var userId = User.GetCurrentUserId();
var result = await _orderService.CreateNewContactInfoByClient(model, userId);
switch (result)
{
case CreateCartAddressResult.NotFound:
return RedirectToAction("NotFound", "Home");
case CreateCartAddressResult.AddressIsExists:
ModelState.AddModelError("Address", "This Address is registered Before");
await GetStateAndDistricts();
return RedirectToAction("ShowCart", "Home");
case CreateCartAddressResult.Success:
TempData[SuccessMessage] = "New Address Was Registered Successfully";
await GetStateAndDistricts();
return RedirectToAction("ShowCart", "Home");
}
await GetStateAndDistricts();
return RedirectToAction("ShowCart", "Home");
}
and this is main methd to show cart:
[HttpGet("/UserPanel/ShowCart")]
public async Task<IActionResult> ShowCart()
{
var text = await _siteService.GetSiteSettingForEdit();
var tax = text.Tax;
var userId = User.GetCurrentUserId();
// Get From Session
var cartItems = _siteService.GetFromSession();
// Update ClientId In ShowCart after Login
foreach (var item in cartItems)
{
if (item.ClientId == 0)
{
item.ClientId = userId;
}
}
// Get user addresses
var userAddresses = await _orderService.GetClientContactInfoById(userId);
// we check it in repo and create a list:
// List<CartAddressViewModel> cartAddresses = new List<CartAddressViewModel>();
//so we don't need to check if null, because in repo 100% create a list for it with object, but not null
// Create CartViewModel
var cartViewModel = new CartViewModel
{
Items = cartItems,
Tax = tax,
CartAddresses = userAddresses
};
await GetStateAndDistricts();
return View(cartViewModel);
}
How can I return to second tab of view of show cart?
this is part of view of showcart:
<section id=" ">
<form action="#">
@if (Model.CartAddresses.Any())
{
foreach (var cartAddress in Model.CartAddresses)
{
<div class="row mb-3">
<div class="col-lg-12">
<div class="input-group mb-3">
<div class="input-group-prepend">
<div class="input-group-text">
<input type="radio" checked="checked" >
</div>
</di