public ActionResult Delete(long id) { var result = _addressService.RemoveAddress(id); if (result.Succedeed) { // CheckOutDTO checkOut = Session["checkout"] as CheckOutDTO; // var index=checkOut.AvailableAddresses.FindIndex(ad => ad.Id == id); // checkOut.AvailableAddresses.Remove(checkOut.AvailableAddresses[index]); if (checkout.SelectedBillingAddressId == id) { _checkOutService.SetBillingAddress(User.Identity.GetUserId(), checkout.AvailableAddresses.Where(ad => ad.IsDefault).FirstOrDefault().Id); } // checkOut.SelectedBillingAddressId = // checkOut.AvailableAddresses.Where(ad => ad.IsDefault).FirstOrDefault().Id; if (checkout.SelectedShippingAddressId == id) { _checkOutService.SetShippingAddress(User.Identity.GetUserId(), checkout.AvailableAddresses.Where(ad => ad.IsDefault).FirstOrDefault().Id); } // checkOut.SelectedShippingAddressId = // checkOut.AvailableAddresses.Where(ad => ad.IsDefault).FirstOrDefault().Id; // Session["checkout"] = checkOut; } return(Json(result)); }