Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Title                   = "Envio de orçamento - Tratorfix Parafusos";
            envioForm.Visible       = true;
            checkoutMessage.Visible = false;
            if (IsPostBack)
            {
                Orçamento myOrder = new Orçamento();
                if (TryUpdateModel(myOrder,
                                   new FormValueProvider(ModelBindingExecutionContext)))
                {
                    myOrder.LinhasOrçamento = new List <LinhaOrçamento>();
                    Carrinho myCart = SessionHelper.GetCarrinho(Session);
                    foreach (CartLine line in myCart.Lines)
                    {
                        myOrder.LinhasOrçamento.Add(new LinhaOrçamento
                        {
                            Orçamento = myOrder,
                            Produto   = line.Product
                        });
                    }
                    new Repository().SaveOrder(myOrder);
                    myCart.Clear();

                    envioForm.Visible = false;
                    EnviarOrçamento(myOrder);
                    checkoutMessage.Visible = true;
                }
            }
        }