public ActionResult AdicionaAoCarrinhoTrad(CarrinhoTrad item) { if (ModelState.IsValid) { item.ValorTotal = item.Valor * item.Qtde; CarrinhoTradTemp.ArmazenaItens(item); return(RedirectToAction("ListaCarrinhoTrad", "Cliente")); } return(View()); }
public ActionResult FinalizarPedidoTrad(FinalizaPedidoTrad tr) { using (EconobuyEntities db = new EconobuyEntities()) { int cli_id = Convert.ToInt32(Session["clienteID"]); int end_id = db.tb_cliente.Where(x => x.cli_in_codigo == cli_id).Select(x => x.end_in_codigo).SingleOrDefault(); int mer_id = Convert.ToInt32(Session["mercadoTradID"]); var ped = new tb_pedido { cli_in_codigo = cli_id, mer_in_codigo = mer_id, data_dt_pedido = DateTime.Now, end_in_codigo = end_id, ped_status = "Aguardando", ped_st_msg = "", ped_dec_valor = 0 }; db.tb_pedido.Add(ped); decimal valor = 0; var carrinho = CarrinhoTradTemp.RetornaItens().ToList(); foreach (var pro in carrinho) { var item = new tb_item { prod_in_codigo = pro.ProdID, ped_in_codigo = ped.ped_in_codigo, item_in_qtde = pro.Qtde, item_dec_valor = pro.ValorTotal }; valor += pro.ValorTotal; db.tb_item.Add(item); } ped.ped_dec_valor = valor; db.SaveChanges(); Session["mercadoTradID"] = null; Session["Itens"] = null; return(RedirectToAction("VisualizarPedido", "Cliente", new { Id = ped.ped_in_codigo })); } }
public ActionResult FinalizaPedidoTrad() { decimal valor = 0; var carrinho = CarrinhoTradTemp.RetornaItens().ToList(); foreach (var item in carrinho) { valor += item.ValorTotal; } int Id = Convert.ToInt32(Session["mercadoTradID"]); using (EconobuyEntities db = new EconobuyEntities()) { var model = (from av in db.tb_avaliacao_mercado join mer in db.tb_mercado on av.mer_in_codigo equals mer.mer_in_codigo join en in db.tb_endereco on mer.end_in_codigo equals en.end_in_codigo where mer.mer_in_codigo == Id select new FinalizaPedidoTrad { Mercado = mer.mer_st_nome, AvMer = av.av_mer_dec_nota, CEP = en.end_st_CEP, Cidade = en.end_st_cidade, Bairro = en.end_st_bairro, Logradouro = en.end_st_log, Complemento = en.end_st_compl, Email = mer.mer_st_email, Telefone_1 = en.end_st_tel1, Telefone_2 = en.end_st_tel2, Valor = valor } ).First(); model.Carrinho = carrinho; return(View(model)); } }
public ActionResult AdicionaAoCarrinhoTrad(CarrinhoTrad c) { if (ModelState.IsValid) { int qtde = 0; int id = 0; if (Session["ItensTrad"] != null) { foreach (var item in CarrinhoTradTemp.RetornaItens()) { if (item.ProdID == c.ProdID) { qtde = item.Qtde + c.Qtde; id = item.Id; c.Qtde = qtde; } } c.ValorTotal = c.Valor * c.Qtde; if (qtde == 0) { CarrinhoTradTemp.ArmazenaItens(c); } else { CarrinhoTradTemp.RemoveItem(id); CarrinhoTradTemp.ArmazenaItens(c); } } else { c.ValorTotal = c.Valor * c.Qtde; CarrinhoTradTemp.ArmazenaItens(c); } return(RedirectToAction("ListaCarrinhoTrad", "Cliente")); } return(View()); }
public ActionResult DeletaItemCarrinhoTrad(int id) { CarrinhoTradTemp.RemoveItem(id); return(RedirectToAction("ListaCarrinhoTrad", "Cliente")); }
public ActionResult ListaCarrinhoTrad() { var carrinho = CarrinhoTradTemp.RetornaItens(); return(View(carrinho)); }