public int Cadastrar(VendaComComandaAtiva vendaComandaAtiva) { try { InstanciaBanco(); _banco.Entry(vendaComandaAtiva).State = EntityState.Added; return _banco.SaveChanges(); } catch (CustomException erro) { throw new CustomException(erro.Message); } catch (Exception erro) { throw new Exception(erro.Message); } }
private VendaComComandaAtiva PupularVendaComComandaAtivaPeso(Produto produto, decimal peso) { try { int pesoTemp = Convert.ToInt32(peso); InstanciarComandaRepositorio(); VendaComComandaAtiva venda = new VendaComComandaAtiva(); venda.IDComanda = _comandaRepositorio.GetIDPeloCodigo(txtCodigoDaComanda.Text).ID; venda.IDProduto = produto.ID; venda.PrecoTotal = (produto.PrecoVenda / 1000) * peso; venda.Quantidade = -pesoTemp; return venda; } catch (CustomException erro) { throw new CustomException(erro.Message); } catch (Exception erro) { throw new Exception(erro.Message); } }
private void InstanciarVendaComComandaAtiva() { _vendaComComandaAtiva = new VendaComComandaAtiva(); }