public ActionResult RemoveItemFromCurrentOrder(int ProductId) { if (Session["ListOrderItem"] != null) { ListItem = (List <OrderItemViewModels>)Session["ListOrderItem"]; } OrderRemoveViewModels model = new OrderRemoveViewModels(); model.ProductId = ProductId; model.ListOrderItem = ListItem; string json = JsonConvert.SerializeObject(model); var buffer = System.Text.Encoding.UTF8.GetBytes(json); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); string ApiEndPoint2 = ApiUrl + "api/OrderApi/RemoveItem/"; HttpClient client2 = new HttpClient(); HttpResponseMessage response2 = client2.PostAsync(ApiEndPoint2, byteContent).Result; string ListResult2 = response2.Content.ReadAsStringAsync().Result.ToString(); var RemoveItemvarian = JsonConvert.DeserializeObject <List <OrderItemViewModels> >(ListResult2); Session["ListOrderItem"] = RemoveItemvarian; ViewBag.GrandTotal = RemoveItemvarian.Sum(s => s.TotalAmount); return(PartialView("_ListOrderItem", RemoveItemvarian)); }
public List <OrderItemViewModels> RemoveItem(OrderRemoveViewModels OrderRemoveItem) { for (int i = 0; i < OrderRemoveItem.ListOrderItem.Count; i++) { if (OrderRemoveItem.ListOrderItem[i].ProductId == OrderRemoveItem.ProductId) { OrderRemoveItem.ListOrderItem.Remove(OrderRemoveItem.ListOrderItem[i]); break; } } return(OrderRemoveItem.ListOrderItem); }
public List <OrderItemViewModels> RemoveItem(OrderRemoveViewModels OrderRemoveItem) { var result = service.RemoveItem(OrderRemoveItem); return(result); }