示例#1
0
        public void CreatePedido()
        {
            if (Id != 0)
            {
                throw new MercurioCoreException("Objeto já criado no Banco de Dados");
            }

            if (Rota == null || Items.Count == 0)
            {
                throw new MercurioCoreException("Falta dados para a criação");
            }

            if (Rota.Id == 0)
            {
                Rota.CreateRota();
            }
            foreach (Item i in Items)
            {
                if (i.Id == 0)
                {
                    i.CreateItem();
                }
            }
            if (Usuario.Id == 0)
            {
                Usuario.CreateUsuario();
            }


            PedidoManipulation item = new PedidoManipulation();

            Pedido novo = item.Create(this);

            Id = novo.Id;
        }
示例#2
0
        public void UpdatePedido()
        {
            foreach (Item i in Items)
            {
                if (i.Id == 0)
                {
                    i.CreateItem();
                }
            }
            if (Rota.Id == 0)
            {
                Rota.CreateRota();
            }
            PedidoManipulation item = new PedidoManipulation();

            item.Update(this);

            foreach (Item i in Items)
            {
                if (i.RemoveItem)
                {
                    Items.Remove(i);
                }
            }
        }