Пример #1
0
 public RecordeVenda(DateTime data, double quantia, StatusVenda statusVenda, Vendedor vendedor)
 {
     Data     = data;
     Quantia  = quantia;
     Status   = statusVenda;
     Vendedor = vendedor;
 }
Пример #2
0
        private bool IsAtualizacaoStatusValida(VendaModel venda, StatusVenda novoStatus)
        {
            if (venda.Status == StatusVenda.ConfirmacaoPagamento && novoStatus == StatusVenda.PagamentoAprovado)
            {
                return(true);
            }
            else if (venda.Status == StatusVenda.ConfirmacaoPagamento && novoStatus == StatusVenda.Cancelada)
            {
                return(true);
            }
            else if (venda.Status == StatusVenda.PagamentoAprovado && novoStatus == StatusVenda.EmTransporte)
            {
                return(true);
            }
            else if (venda.Status == StatusVenda.PagamentoAprovado && novoStatus == StatusVenda.Cancelada)
            {
                return(true);
            }
            else if (venda.Status == StatusVenda.EmTransporte && novoStatus == StatusVenda.Entregue)
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
        public async Task <IActionResult> AtualizarStatus([FromRoute] int id, StatusVenda novoStatus)
        {
            try
            {
                if (id <= 0)
                {
                    return(BadRequest("O identificador da venda deve ser informado!"));
                }

                if (!this._vendaDal.VerificarIdExiste(id))
                {
                    return(NotFound($"O identificador da venda {id} informado não foi encontrado!"));
                }

                var _vendaModel = this._vendaDal.BuscarPorId(id);

                if (!this.IsAtualizacaoStatusValida(_vendaModel, novoStatus))
                {
                    return(BadRequest($"A transição do status {GetDescricaoStatus(_vendaModel.Status)} para o status {GetDescricaoStatus(novoStatus)} não é válida!"));
                }

                await this._vendaDal.AtualizarStatus(id, novoStatus);

                return(Ok());
            }
            catch (Exception Ex)
            {
                return(BadRequest($"Ocorreu o seguinte erro no método AtualizarStatus.Erro: {Ex.Message}"));
            }
        }
Пример #4
0
        public async Task <bool> AtualizarStatusAsync(Guid identificador, StatusVenda novoStatusVenda)
        {
            var vendaParaAtualizar = await ObterPorIdAsync(identificador);

            //Obtém as configurações de transições possíveis entre os status de venda.
            var configuracaoTransicaoStatusPossivel = ObterConfiguracaoTransicoesStatus();

            //Obtém os status permitidos, baseado na configuração e no status atual da venda.
            var transicoesPossiveis = configuracaoTransicaoStatusPossivel
                                      .Where(t => t.StatusAtual == vendaParaAtualizar.Status)
                                      .Select(r => r.StatusPermitido);

            //Verifica se o novo status para a venda é permitido.
            if (!transicoesPossiveis.Contains(novoStatusVenda))
            {
                throw new TransicaoStatusVendaInvalidaException(vendaParaAtualizar.Status, novoStatusVenda);
            }

            vendaParaAtualizar.Status = novoStatusVenda;

            var operacaoRealizada = await vendaSqlAdapter
                                    .AtualizarStatusAsync(vendaParaAtualizar);

            return(operacaoRealizada);
        }
Пример #5
0
    public async Task <ActionResult <StatusVenda> > Put(
        int id,
        [FromServices] DataContext context,
        [FromBody] StatusVenda model)
    {
        if (id != model.Id)
        {
            return(NotFound(new { message = "Não encontrado" }));
        }

        if (!ModelState.IsValid)
        {
            return(BadRequest(ModelState));
        }

        try
        {
            context.Entry <StatusVenda>(model).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok(model));
        }
        catch (DbUpdateConcurrencyException)
        {
            return(BadRequest(new { message = "Registro ja fpoi atualizado" }));
        }
        catch
        {
            return(BadRequest(new { message = "Não foi possivel atualizar o cadastro" }));
        }
    }
Пример #6
0
 public RegistroVendas(int id, DateTime date, double valor, StatusVenda status, Vendedor vendedor)
 {
     Id       = id;
     Date     = date;
     Valor    = valor;
     Status   = status;
     Vendedor = vendedor;
 }
 public RegistroVendas(int id, DateTime data, double total, StatusVenda status, Vendedor vendedor)
 {
     Id       = id;
     Data     = data;
     Total    = total;
     Status   = status;
     Vendedor = vendedor;
 }
Пример #8
0
 public RegistroDeVendas(int id, DateTime dataDaVenda, double valor, StatusVenda status, Vendedores vendedor)
 {
     Id          = id;
     DataDaVenda = dataDaVenda;
     Valor       = valor;
     Status      = status;
     Vendedor    = vendedor;
 }
Пример #9
0
 public Venda(int id, DateTime dataDeVenda, double total, StatusVenda status, Vendedor vendedor)
 {
     Id          = id;
     DataDeVenda = dataDeVenda;
     Total       = total;
     Status      = status;
     Vendedor    = vendedor;
 }
Пример #10
0
 public Venda(int id, DateTime data, double total, StatusVenda status, Vendedor vendedor)
 {
     this.id       = id;
     this.data     = data;
     this.total    = total;
     this.status   = status;
     this.vendedor = vendedor;
 }
Пример #11
0
 public RegistroDeVenda(int id, DateTime data, double quantia, StatusVenda status, Vendedor vendedor)
 {
     Id       = id;
     Data     = data;
     Quantia  = quantia;
     Status   = status;
     Vendedor = vendedor;
 }
Пример #12
0
 public Venda(long clienteId, StatusVenda status, decimal valorTotal, decimal valorFrete, decimal valorProduto)
 {
     ClienteId    = clienteId;
     Status       = status;
     ValorTotal   = valorTotal;
     ValorFrete   = valorFrete;
     ValorProduto = valorProduto;
 }
Пример #13
0
 public Venda(int id, DateTime dataVenda, double valorTotal, StatusVenda status, Vendedor vendedor)
 {
     Id = id;
     DataVenda = dataVenda;
     ValorTotal = valorTotal;
     Status = status;
     Vendedor = vendedor;
 }
Пример #14
0
 public RegistroVendas(int id, DateTime data, double quantidade, StatusVenda status, Vendedor vendedor)
 {
     Id         = id;
     Data       = data;
     Quantidade = quantidade;
     Status     = status;
     Vendedor   = vendedor;
 }
Пример #15
0
 public RecordVendas(int id, DateTime data, double valor, StatusVenda status, Vendedor vendedor)
 {
     Id       = id;
     Data     = data;
     Total    = valor;
     Status   = status;
     Vendedor = vendedor;
 }
Пример #16
0
 public RegistrosdeVendas(int id, DateTime data, double montante, StatusVenda status, Vendedor vendedor)
 {
     Id       = id;
     Data     = data;
     Montante = montante;
     Status   = status;
     Vendedor = vendedor;
 }
Пример #17
0
 public VendaGravada(int id, DateTime data, double valor, StatusVenda status, Vendedor vendedor)
 {
     Id       = id;
     Data     = data;
     Valor    = valor;
     Status   = status;
     Vendedor = vendedor;
 }
Пример #18
0
 public TotalVendas(int v1, DateTime dateTime, double v2, StatusVenda faturado, Vendedor v5)
 {
     this.v1       = v1;
     this.dateTime = dateTime;
     this.v2       = v2;
     this.faturado = faturado;
     this.v5       = v5;
 }
Пример #19
0
 public RegistroDeVenda(int id, DateTime data, int valor, StatusVenda status, Vendedor vendedor)
 {
     Id            = id;
     Data          = data;
     this.Valor    = valor;
     this.Status   = status;
     this.vendedor = vendedor;
 }
Пример #20
0
 public Vendas(int id, DateTime date, double total, StatusVenda status, Vendedor vendedor)
 {
     Id         = id;
     Date       = date;
     this.total = total;
     Status     = status;
     Vendedor   = vendedor;
 }
Пример #21
0
 public RegistroVendas(int id, DateTime dataVenda, double valorVenda, StatusVenda status, Vendedor vendedor)
 {
     Id         = id;
     DataVenda  = dataVenda;
     ValorVenda = valorVenda;
     Status     = status;
     Vendedor   = vendedor;
 }
Пример #22
0
 public Venda(int id, DateTime dataVenda, double valorTotal, StatusVenda status, Vendedor vendedor)
 {
     this.Id         = id;
     this.DataVenda  = dataVenda;
     this.ValorTotal = valorTotal;
     this.Status     = status;
     this.Vendedor   = vendedor;
 }
Пример #23
0
 public VendasRegistro(int id, DateTime date, double amount, StatusVenda status, Vendedor vendedor)
 {
     Id       = id;
     Date     = date;
     Amount   = amount;
     Status   = status;
     Vendedor = vendedor;
 }
 public void Validate()
 {
     AddNotifications(new Contract()
                      .Requires().IsTrue(new StatusExists(StatusVenda.ToString()).enumValue(), nameof(StatusVenda), "Status de venda não está correto!")
                      .Requires().IsNotNull(IdVendedor, nameof(IdVendedor), "Por Favor, insira um ID de vendedor!")
                      .Requires().IsNotNullOrEmpty(Data.ToString(), nameof(Data), "Data não pode estar vazio!")
                      .Requires().IsNotNull(Veiculo, nameof(Veiculo), "Deve haver um veiculo preenchido!")
                      );
 }
Пример #25
0
        public async Task AtualizarStatus(int codigoVenda, StatusVenda novoStatus)
        {
            var _venda = this._apiContext.Vendas.Where(i => i.Id == codigoVenda).SingleOrDefault();

            if (_venda != null)
            {
                _venda.Status = novoStatus;
                await this._apiContext.SaveChangesAsync();
            }
        }
Пример #26
0
 public ActionResult AtualizarStatus(int?id)
 {
     if (id == null)
     {
         return(NotFound());
     }
     ViewBag.Status         = StatusVenda.GetStatusVenda();
     ViewBag.FormaPagamento = FormaPagamento.GetFormaPagamento();
     return(View(Mapper.Map <Venda, VendaViewModel>(_vendaService.GetById((int)id))));
 }
Пример #27
0
 private static bool TryValidStatus(StatusVenda statusVendaNew, StatusVenda statusVendaOld)
 {
     if (statusVendaNew != statusVendaOld)
     {
         return(statusVendaOld switch
         {
             StatusVenda.ConfirmacaoPagamento => statusVendaNew == StatusVenda.PagamentoAprovado || statusVendaNew == StatusVenda.Cancelada,
             StatusVenda.PagamentoAprovado => statusVendaNew == StatusVenda.EmTransporte || statusVendaNew == StatusVenda.Cancelada,
             StatusVenda.EmTransporte => statusVendaNew == StatusVenda.Entregue,
             _ => false,
         });
Пример #28
0
        public static int VendaAtualizar(Ioc.Core.Data.Venda venda, StatusVenda status)
        {
            Veiculos.Ioc.Service.Service <Ioc.Core.Data.Venda> service = new Ioc.Service.Service <Ioc.Core.Data.Venda>();

            if (venda.Id > 0)
            {
                venda = service.Buscar(f => f.Id == venda.Id);
            }

            venda.IdStatusVenda = (int)status;

            return(service.Atualizar(venda));
        }
Пример #29
0
        public ActionResult Pedidos()
        {
            var userId = new Guid(User.FindFirstValue(ClaimTypes.NameIdentifier));
            var vendas = _vendaService.GetByCustomer(userId);

            if (vendas == null)
            {
                return(NotFound());
            }
            ViewBag.Status         = StatusVenda.GetStatusVenda();
            ViewBag.FormaPagamento = FormaPagamento.GetFormaPagamento();
            return(View(Mapper.Map <IEnumerable <Venda>, IEnumerable <VendaViewModel> >(vendas)));
        }
Пример #30
0
        public ActionResult Vendas()
        {
            var userId = new Guid(User.FindFirstValue(ClaimTypes.NameIdentifier));
            var vendas = _vendaService.GetBySeller(userId);

            if (vendas == null)
            {
                return(NotFound());
            }
            ViewBag.Avaliacao      = _vendaService.RateById(userId).ToString().Replace(',', '.');
            ViewBag.Status         = StatusVenda.GetStatusVenda();
            ViewBag.FormaPagamento = FormaPagamento.GetFormaPagamento();
            return(View(Mapper.Map <IEnumerable <Venda>, IEnumerable <VendaViewModel> >(vendas)));
        }