コード例 #1
0
        protected override void Insert(Venda entity)
        {
            if (entity.DiaVencimento == 0)
            {
                throw new Exception("O dia de vencimento deve ser informada corretamente.");
            }

            using (var scope = new TransactionScope())
            {
                var loteBo       = new LoteLogic();
                var loteamentoBo = new LoteamentoLogic();
                var lote         = loteBo.Get(entity.LoteId);

                if (lote.Comprado)
                {
                    throw new Exception("O lote selecionado foi comprado por outra pessoa enquanto você concluía sua aquisição.\nPor favor, selecione outro lote.");
                }

                lote.Comprado = true;
                loteBo.Save(lote);

                if (lote.LoteamentoId != null)
                {
                    lote.Loteamento = loteamentoBo.Get((long)lote.LoteamentoId);
                }

                if (entity.QuantParcelas < 1 || entity.QuantParcelas > lote.Loteamento.QuantParcelas)
                {
                    throw new Exception($"A quantidade de parcelas deve estar entre 1 e {lote.Loteamento.QuantParcelas}.");
                }

                entity.Valor        = lote.Valor;
                entity.ValorParcela = entity.Valor / entity.QuantParcelas;
                entity.DataHora     = DateTime.Now;

                base.Insert(entity);

                var tituloBo = new TituloLogic();
                tituloBo.GerarTitulos(entity.Id);

                scope.Complete();
            }
        }
コード例 #2
0
        public IEnumerable <Venda> ListPorEmpresa(long empresaId)
        {
            var vendas = _dao.ListPorCliente(empresaId);

            var parametroBo = new ParametroLogic();
            var parametro   = parametroBo.Get(1);

            var tituloBo = new TituloLogic();


            foreach (var venda in vendas)
            {
                var titulos = new List <Titulo>();
                titulos     = tituloBo.List(venda.Id).ToList();
                venda.Pagas = titulos.Where(x => x.Pago == true).Count();
            }

            return(vendas);
        }
コード例 #3
0
 public VendaLogic()
 {
     _tituloBo = new TituloLogic();
 }
コード例 #4
0
 public DashboardClienteLogic()
 {
     _vendaBo  = new VendaLogic();
     _tituloBo = new TituloLogic();
 }