K
K
Kolian_Parasochka2019-09-06 08:45:39
ASP.NET
Kolian_Parasochka, 2019-09-06 08:45:39

How to solve JSON handling issue in ASP Net MVC 5?

The bottom line is that after the method works, I have:
public JsonResult JsonShowProducts(string emailCart)
{
Cart cart = repository.GetCart(emailCart);
return Json(productFunc.ToProductResults(cart.Products), JsonRequestBehavior.AllowGet);
}
outputs [{"Sum":780,"Brand":"Versace","Category":"T-shirts"},{"Sum":650,"Brand":"Calvin clain","Category":"T-shirts" },{"Sum":3100,"Brand":"J.Crew.","Category":"Pants"}] under the link " localhost:49827/Admin/JsonShowProducts " and should display in the view " localhost:49827 /Admin/Index ".
Here is the code from the Index client side:
@{
ViewBag.Title = "Index";
}
Administrator
@if (ViewBag.CountCarts > 0)
{
List of buyers

SurnameNameThe address
@el.LastName@el.Name@el.HomeAddress
using (Ajax.BeginForm("JsonShowProducts", new AjaxOptions { OnSuccess = "OnSuccess" }))
{
}

using (Html.BeginForm("Agree", "Admin", FormMethod.Post))
{
}

}
Goods in stock
BrandCategoryColourPrice
@el.Brand@el.Category@el.Color@el.Sum
@if (!el.IsRemoved)
{
using (Html.BeginForm("DeleteProduct", "Admin", FormMethod.Post))
{
}
}
else
{
using (Html.BeginForm("ReturnProduct", "Admin", FormMethod.Post ))
{
}
}

@Html.ActionLink("Add Product", "AddProduct", "Admin", new { @class = "btn btn-default" })
@section scripts {
}
@Scripts.Render("~/scripts/jquery-1.10. 2.min.js")
@Scripts.Render("~/scripts/jquery.unobtrusive-ajax.min.js")
The ProductResult class that is converted to Json
public class ProductResult
{
public int Sum { get; set; }
public string Brand { get; set; }
public string Category { get; set; }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question