public JsonResult AgregarProductoCarrito(int iIdProducto) { string cMensaje; string cIcono; try { if (producto.ChecarExistencia(iIdProducto)) { int iIdCarrito = carrito.ObtenerCarrito(Convert.ToInt32(Session["iIdCliente"])); if (carrito.AgregarAcarrito(iIdProducto, iIdCarrito)) { cMensaje = "Se ha agregado un producto al carrito."; cIcono = "success"; } else { cMensaje = "La existencia disponible se ha agregado al carrito."; cIcono = "error"; } } else { cMensaje = "No hay existencia disponible para este producto."; cIcono = "error"; } } catch (Exception) { cMensaje = "Ha ocurrido un error"; cIcono = "error"; } return(Json(new { cMensaje, cIcono })); }