public OfertaPedido FindOferta(int idOferta) { OfertaPedido obj = new OfertaPedido(); obj = ofertas.FirstOrDefault(x => x.IdOfertaPedido == idOferta); return(obj); }
private void AgregarOfertasPorPedido(Pedido pedido) { int idPedido = pedido.IdPedido; foreach (OfertaPedido item in carrito.GetListOfertas()) { //Agregar Alimento a la tabla OfertaPedido Oferta oferta = oDAL.Find(Convert.ToInt32(item.IdOferta)); int idOfertaPedidoLista = item.IdOfertaPedido; OfertaPedido alimentoPedido = oPDAL.Add(new OfertaPedido() { IdOferta = oferta.IdOferta, IdPedido = idPedido }); //Restar el stock del ingrediente respecto a los ingredientes de los alimentos de la oferta List <OfertaAlimento> listaAlimentos = oADAL.getAlimentosOferta(oferta.IdOferta); foreach (OfertaAlimento alimento in listaAlimentos) { List <IngredientesAlimento> lista = iADAL.GetIngredientesByAlimento((int)alimento.IdAlimento); foreach (IngredientesAlimento ingAl in lista) { Ingrediente ingrediente = iDAL.Find((int)ingAl.Ingrediente); ingrediente.Stock -= ingAl.Cantidad; iDAL.Update(ingrediente); } } } }
public OfertaPedido Add(OfertaPedido m) { OfertaPedido obj = nowBDEntities.OfertaPedido.Add(m); nowBDEntities.SaveChanges(); return(obj); }
private void ActivarPopUpOferta(OfertaPedido oferta) { Oferta obj = oDAL.Find(oferta.IdOferta.Value); ListViewAlimentos.DataSource = oADAL.getAllAlimentos(obj.IdOferta); ListViewAlimentos.DataBind(); ModalPopupExtender2.Show(); }
public void RemoveOferta(OfertaPedido oferta) { try { ofertas.Remove(oferta); } catch (Exception e) { throw new Exception(e.Message); } }
private void AgregarOfertasPorPedido(Pedido pedido) { int idPedido = pedido.IdPedido; foreach (OfertaPedido item in carrito.GetListOfertas()) { int idOferta = item.IdOferta.Value; OfertaPedido ofertaPedido = oPDAL.Add(new OfertaPedido() { IdOferta = idOferta, IdPedido = idPedido }); RestarStockOferta(idOferta); } }
protected void GridViewPedido_RowCommand(object sender, GridViewCommandEventArgs e) { try { int index = Convert.ToInt32(e.CommandArgument); int idAlimentoPedido = Convert.ToInt32(((Label)GridViewPedido.Rows[index].FindControl("lblIdAlimentoPedido")).Text); string tipoElemento = ((Label)GridViewPedido.Rows[index].FindControl("lblTipoElemento")).Text; AlimentoPedido objCarritoAlimento = null; OfertaPedido objCarritoOferta = null; if (tipoElemento == "Alimento") { objCarritoAlimento = carrito.FindAlimento(idAlimentoPedido); } else if (tipoElemento == "Oferta") { objCarritoOferta = carrito.FindOferta(idAlimentoPedido); } switch (e.CommandName) { case "Quitar": if (tipoElemento == "Alimento") { carrito.RemoveAlimento(objCarritoAlimento); } else if (tipoElemento == "Oferta") { carrito.RemoveOferta(objCarritoOferta); } CargarTotales(); break; case "AgregarExtra": ActivarPopUpExtra(objCarritoAlimento); break; case "Ver Oferta": ActivarPopUpOferta(objCarritoOferta); break; } CargarGridCarrito(); } catch (Exception ex) { UserMessage(ex.Message, "danger"); } }
protected void GridCarrito_RowCommand(object sender, GridViewCommandEventArgs e) { try { int index = Convert.ToInt32(e.CommandArgument); Label lblIdAlimentoPedido = (Label)((GridView)sender).Rows[index].FindControl("lblCodigoElementoPedido"); string tipoElemento = ((Label)((GridView)sender).Rows[index].FindControl("lblTipoElemento")).Text; AlimentoPedido objCarritoAlimento = null; OfertaPedido objCarritoOferta = null; if (tipoElemento == "Alimento") { objCarritoAlimento = carrito.FindAlimento(int.Parse(lblIdAlimentoPedido.Text)); } else if (tipoElemento == "Oferta") { objCarritoOferta = carrito.FindOferta(int.Parse(lblIdAlimentoPedido.Text)); } switch (e.CommandName) { case "ShowExtras": FillModal(Convert.ToInt32(lblIdAlimentoPedido.Text)); break; case "deleteAlimento": if (tipoElemento == "Alimento") { carrito.RemoveAlimento(objCarritoAlimento); } else if (tipoElemento == "Oferta") { carrito.RemoveOferta(objCarritoOferta); } CargarTotales(); CargarGridCarrito(); break; } } catch (Exception ex) { UserMessage(ex.Message, "danger"); } }
public void RemoveOferta(OfertaPedido oferta) { carritoOfertas.RemoveOferta(oferta); }