33 lines
872 B
Elixir
33 lines
872 B
Elixir
|
defmodule BrightWeb.CartController do
|
||
|
use BrightWeb, :controller
|
||
|
alias Bright.ShoppingCart
|
||
|
def show(conn, _params) do
|
||
|
render(conn, :show, changeset: ShoppingCart.change_cart(conn.assigns.cart))
|
||
|
# render(conn, :show)
|
||
|
end
|
||
|
def update(conn, %{"cart" => cart_params}) do
|
||
|
case ShoppingCart.update_cart(conn.assigns.cart, cart_params) do
|
||
|
{:ok, _cart} ->
|
||
|
redirect(conn, to: ~p"/cart")
|
||
|
|
||
|
{:error, _changeset} ->
|
||
|
conn
|
||
|
|> put_flash(:error, "There was an error updating your cart")
|
||
|
|> redirect(to: ~p"/cart")
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
# def show(conn, %{"id" => id}) do
|
||
|
# product = Catalog.get_product!(id)
|
||
|
# render(conn, :show, product: product)
|
||
|
# end
|
||
|
|
||
|
# def show(conn, %{"id" => id}) do
|
||
|
# stream =
|
||
|
# id
|
||
|
# |> Streams.get_stream!()
|
||
|
# |> Streams.inc_page_views()
|
||
|
|
||
|
# render(conn, :show, stream: stream)
|
||
|
# end
|