Ejemplo n.º 1
0
        public async Task Add(Representante representante)
        {
            string sql       = "INSERT INTO [representantes] (id, nome, telefone) VALUES (@id, @nome, @telefone)";
            var    sqlParams = new { id = representante.Id, nome = representante.Nome, telefone = representante.Telefone };

            await Execute(sql, sqlParams);
        }
Ejemplo n.º 2
0
        public void Quando_criar_uma_Venda_as_Comissões_devem_ser_geradas()
        {
            // arrage
            var produto1       = new Produto("H2OH 500 ml", 3.00m);
            var produto2       = new Produto("H2OH 1,5 l", 4.50m);
            var produto3       = new Produto("Café Pilão 500 g", 8.00m);
            var representante1 = new Representante("234567", "Antonio de Souza", 2);
            var representante2 = new Representante("345678", "Rafael de Moura", 3);
            var cliente        = new Cliente("123456", 1000, "José da Silva");
            var item1          = new ItemDaVenda(produto1, 2, representante1, "Item 1");
            var item2          = new ItemDaVenda(produto2, 5, representante1, "Item 2");
            var item3          = new ItemDaVenda(produto3, 1, representante2, "Item 3");
            var itensDaNota    = new HashSet <ItemDaVenda> {
                item1, item2, item3
            };

            // act
            var venda = new Venda(cliente, 98765432, new DateTime(2016, 03, 10),
                                  new DateTime(2016, 03, 10), "3 Itens", itensDaNota);

            // assert
            Assert.AreEqual(2, venda.Comissoes.Count);

            var comissao1 = venda.Comissoes.Single(c => c.Representante.Equals(representante1));

            Assert.AreEqual(28.50m, comissao1.ValorDaVenda);
            Assert.AreEqual(0.57m, comissao1.Valor);

            var comissao2 = venda.Comissoes.Single(c => c.Representante.Equals(representante2));

            Assert.AreEqual(8.00m, comissao2.ValorDaVenda);
            Assert.AreEqual(0.24m, comissao2.Valor);
        }
Ejemplo n.º 3
0
    public static void Main(string[] args)
    {
        Empreendedor BBQ = new Empreendedor("001", "BBQ", "127.576.567-08", "988484960", "Comercio");

        BBQ.getMeuEndereco().setRua("Pinga da Boa");
        BBQ.getMeuEndereco().setNumero("51");
        BBQ.getMeuEndereco().setBairro("Cachaça não falta");
        BBQ.getMeuEndereco().setMunicipio("Pinguso");
        BBQ.getMeuEndereco().setEstado("CanaBraba");
        BBQ.getMeuEndereco().setPais("Brasil");
        Empreendedor Carlos = new Empreendedor("002", "Carlos", "127.576.567-08", "995174985", "Industria");

        Carlos.getMeuEndereco().setRua("Pinga da Boa");
        Carlos.getMeuEndereco().setNumero("51");
        Carlos.getMeuEndereco().setBairro("Cachaça não falta");
        Carlos.getMeuEndereco().setMunicipio("Pinguso");
        Carlos.getMeuEndereco().setEstado("CanaBraba");
        Carlos.getMeuEndereco().setPais("Brasil");
        Representante MeuRepresentante = new Representante("9000", "Carlistor", "988020547");
        Empresa       MinhaEmpresa     = new Empresa("001", "FRICAO", "2730314512", "Comercio");
        Empresa       OutraEmpresa     = new Empresa("002", "RIGOCAO", "2730544512", "Industria");

        MinhaEmpresa.CadastrarEmpreendedor(BBQ);
        MinhaEmpresa.CadastrarEmpreendedor(Carlos);
        Console.WriteLine();
        Carlos.SelecionarFornecedor();
    }
Ejemplo n.º 4
0
        public ItemDaVenda(Produto produto, int quantidade,
                           Representante representante, string descricao)
        {
            if (string.IsNullOrWhiteSpace(descricao))
            {
                throw new ArgumentOutOfRangeException("descricao");
            }

            if (produto == null)
            {
                throw new ArgumentNullException("produto");
            }

            if (representante == null)
            {
                throw new ArgumentNullException("representante");
            }

            this.Produto       = produto;
            this.ValorUnitario = produto.Preço;
            this.Quantidade    = quantidade;
            this.ValorTotal    = produto.Preço * quantidade;
            this.Representante = representante;
            this.Descricao     = descricao;
        }
Ejemplo n.º 5
0
        //Persistir o objecto e atualizar informações
        private bool atualizar(Representante ORepresentante)
        {
            Representante dbRepresentante = db.Representante.Include(x => x.Pessoa).FirstOrDefault(x => x.id == ORepresentante.id && x.dtExclusao == null);

            if (dbRepresentante == null)
            {
                return(false);
            }

            var RepresentanteEntry = db.Entry(dbRepresentante);

            ORepresentante.setDefaultUpdateValues();
            RepresentanteEntry.CurrentValues.SetValues(ORepresentante);
            RepresentanteEntry.State = EntityState.Modified;
            RepresentanteEntry.ignoreFields(new [] { "idPessoa", "ativo" });

            var PessoaEntry = db.Entry(dbRepresentante.Pessoa);

            ORepresentante.Pessoa.setDefaultUpdateValues();
            ORepresentante.Pessoa.id = dbRepresentante.Pessoa.id;
            PessoaEntry.CurrentValues.SetValues(ORepresentante.Pessoa);
            PessoaEntry.State = EntityState.Modified;
            PessoaEntry.ignoreFields();

            db.SaveChanges();
            return(ORepresentante.id > 0);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> SolicitarCupo()
        {
            ViewData["Usuario"]     = System.Web.HttpContext.Current.Session["Usuario"] as string;
            ViewData["Perfil"]      = System.Web.HttpContext.Current.Session["Perfil"] as string;
            ViewData["CardID"]      = System.Web.HttpContext.Current.Session["CardID"] as string;
            ViewData["ShoppingCar"] = System.Web.HttpContext.Current.Session["ShoppingCar"] as string;

            modelRepresentante = new Representante();
            modelRepresentante = await representante.GetByCardId(System.Web.HttpContext.Current.Session["CID"].ToString());

            ViewBag.Carrito = await carrito.GetByRepresentative(modelRepresentante.Id);

            ViewBag.Pais = await pais.GetAll();

            ViewBag.Estado = await provinciaEstado.GetAll();

            ViewBag.PeriodoEscolar = await periodo.GetAll();

            ViewBag.Grado = await grado.GetAll();

            ViewBag.EstadoCivil = await estadoCivil.GetAll();

            model = new Alumno();

            return(View(model));
        }
        public async Task <IActionResult> PutRepresentante(int id, Representante representante)
        {
            if (id != representante.RepresentanteId)
            {
                return(BadRequest());
            }

            _context.Entry(representante).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RepresentanteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 8
0
        public async Task <ActionResult> Index()
        {
            if (System.Web.HttpContext.Current.Session["ID"].ToString() == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewData["Usuario"]     = System.Web.HttpContext.Current.Session["Usuario"] as string;
                ViewData["Perfil"]      = System.Web.HttpContext.Current.Session["Perfil"] as string;
                ViewData["CardID"]      = System.Web.HttpContext.Current.Session["CardID"] as string;
                ViewData["ShoppingCar"] = System.Web.HttpContext.Current.Session["ShoppingCar"] as string;

                modelRepresentante = new Representante();
                modelRepresentante = await representante.GetByCardId(System.Web.HttpContext.Current.Session["CID"].ToString());

                ViewBag.Carrito = await carrito.GetByRepresentative(modelRepresentante.Id);

                models = new List <Alumno>();
                if (System.Web.HttpContext.Current.Session["Perfil"].ToString() == "Administrador")
                {
                    models = await alumno.GetByPreInscription();
                }
                else
                {
                    models = await alumno.GetByRepresentative(modelRepresentante.Id);
                }

                return(View(models));
            }
        }
        public async Task <ActionResult <Representante> > PostRepresentante(Representante representante)
        {
            _context.Representante.Add(representante);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRepresentante", new { id = representante.Id }, representante));
        }
Ejemplo n.º 10
0
        public void Quando_criar_uma_Venda_as_Comissões_devem_ser_geradas()
        {
            // arrage
            var produto1 = new Produto("H2OH 500 ml", 3.00m);
            var produto2 = new Produto("H2OH 1,5 l", 4.50m);
            var produto3 = new Produto("Café Pilão 500 g", 8.00m);
            var representante1 = new Representante("234567", "Antonio de Souza", 2);
            var representante2 = new Representante("345678", "Rafael de Moura", 3);
            var cliente = new Cliente("123456", 1000, "José da Silva");
            var item1 = new ItemDaVenda(produto1, 2, representante1, "Item 1");
            var item2 = new ItemDaVenda(produto2, 5, representante1, "Item 2");
            var item3 = new ItemDaVenda(produto3, 1, representante2, "Item 3");
            var itensDaNota = new HashSet<ItemDaVenda> { item1, item2, item3 };
            
            // act
            var venda = new Venda(cliente, 98765432, new DateTime(2016, 03, 10),
                new DateTime(2016, 03, 10), "3 Itens", itensDaNota);

            // assert
            Assert.AreEqual(2, venda.Comissoes.Count);

            var comissao1 = venda.Comissoes.Single(c => c.Representante.Equals(representante1));
            Assert.AreEqual(28.50m, comissao1.ValorDaVenda);
            Assert.AreEqual(0.57m, comissao1.Valor);

            var comissao2 = venda.Comissoes.Single(c => c.Representante.Equals(representante2));
            Assert.AreEqual(8.00m, comissao2.ValorDaVenda);
            Assert.AreEqual(0.24m, comissao2.Valor);
        }
Ejemplo n.º 11
0
 internal Comissao(Representante representante, decimal valorDoItem)
 {
     this.Representante        = representante;
     this.PercentualDaComissao = representante.PercentualDeComissao;
     this.ValorDaVenda         = valorDoItem;
     this.Valor = CalcularValorComissao(valorDoItem);
 }
Ejemplo n.º 12
0
        public ActionResult Agregar2(string nombre, string apellido, string parentesco, string telefono)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                Representante rep = new Representante();
                rep.Nombres    = nombre;
                rep.Apellidos  = apellido;
                rep.Parentesco = parentesco;
                rep.Telefono   = Int32.Parse(telefono);

                using (var db = new RepresentanteContext())
                {
                    db.Representante.Add(rep);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Error al agregar Representante");
                return(View());
            }
        }
 public ActionResult GuardarR(Representante repr)
 {
     ViewBag.IdTiendaT = context.Tiendas.ToList();
     validar.ValidarRepresentanteExiste(repr, ModelState);
     serviRe.GuardarRepresentante(repr);
     return(RedirectToAction("Index", repr));
 }
Ejemplo n.º 14
0
        public ActionResult Editar(Representante rep)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                using (var db = new RepresentanteContext())
                {
                    Representante representante = db.Representante.Find(rep.Cedula);

                    representante.Nombres    = rep.Nombres;
                    representante.Apellidos  = rep.Apellidos;
                    representante.Parentesco = rep.Parentesco;
                    representante.Telefono   = rep.Telefono;

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> CuposSolicitados()
        {
            ViewData["Usuario"]     = System.Web.HttpContext.Current.Session["Usuario"] as string;
            ViewData["Perfil"]      = System.Web.HttpContext.Current.Session["Perfil"] as string;
            ViewData["CardID"]      = System.Web.HttpContext.Current.Session["CardID"] as string;
            ViewData["ShoppingCar"] = System.Web.HttpContext.Current.Session["ShoppingCar"] as string;

            modelRepresentante = new Representante();
            modelRepresentante = await representante.GetByCardId(System.Web.HttpContext.Current.Session["CID"].ToString());

            ViewBag.Carrito = await carrito.GetByRepresentative(modelRepresentante.Id);

            modelsCupo = new List <SolicitudCupo>();
            if (System.Web.HttpContext.Current.Session["Perfil"].ToString() == "Administrador")
            {
                modelsCupo = await cupo.GetAll();
            }
            else
            {
                Usuario user = await usuario.GetById(System.Web.HttpContext.Current.Session["CID"].ToString());

                modelsCupo = await cupo.GetByUsuario(user.Id);
            }


            return(View(modelsCupo));
        }
Ejemplo n.º 16
0
        //Verificar se deve-se atualizar um registro existente ou criar um novo
        public bool salvar(Representante ORepresentante)
        {
            if (ORepresentante.id == 0)
            {
                return(this.inserir(ORepresentante));
            }

            return(this.atualizar(ORepresentante));
        }
Ejemplo n.º 17
0
 public Empresa consultarClienteCedula(String cedula)
 {
     conexion              = new Conexion();
     empresaDAO            = new EmpresaDAO(conexion);
     representante         = new Representante();
     empresa               = new Empresa();
     empresa.Representante = new Representante();
     return(empresa = empresaDAO.consultarEmpresa(empresa, cedula));
 }
Ejemplo n.º 18
0
        public Task <bool> Handle(CadastrarRepresentanteCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            var onboarding = _onboardingRepository.Find(o => o.CodigoConvite.Equals(message.CodigoConvite) && o.NumeroCelular.Equals(message.NumeroCelular)).FirstOrDefault();

            if (onboarding == null)
            {
                _bus.RaiseEvent(new DomainNotification(message.MessageType, "Código do convite ou número de celular inválidos.", message));
                return(Task.FromResult(false));
            }

            if (onboarding.Consultor == null)
            {
                _bus.RaiseEvent(new DomainNotification(message.MessageType, "Consultor não cadastrado.", message));
                return(Task.FromResult(false));
            }

            var representante = new Representante(Guid.NewGuid(), message.Cpf, message.NomeCompleto, message.Sexo, message.EstadoCivil,
                                                  message.Nacionalidade, message.DocumentoFrenteBase64, message.DocumentoVersoBase64, onboarding.Consultor.Id);

            _representanteRepository.Add(representante);

            foreach (var value in message.Emails)
            {
                var tipoEmail = (int?)value.GetType().GetProperty("TipoEmail")?.GetValue(value, null);
                var email     = value.GetType().GetProperty("Email")?.GetValue(value, null)?.ToString();

                var representanteEmail = new RepresentanteEmail(Guid.NewGuid(), tipoEmail.GetValueOrDefault(), email, representante.Id);

                _representanteEmailRepository.Add(representanteEmail);
            }

            foreach (var value in message.Telefones)
            {
                var tipoTelefone = (int?)value.GetType().GetProperty("TipoTelefone")?.GetValue(value, null);
                var numero       = value.GetType().GetProperty("Numero")?.GetValue(value, null)?.ToString();

                var representanteTelefone = new RepresentanteTelefone(Guid.NewGuid(), tipoTelefone.GetValueOrDefault(), numero, representante.Id);

                _representanteTelefoneRepository.Add(representanteTelefone);
            }

            onboarding.StatusOnboarding = StatusOnboarding.DadosRepresentante;

            _onboardingRepository.Update(onboarding);

            if (Commit())
            {
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 19
0
 public void modificarEmpresa(int id, int idE, string nombreE, string rucE, string nombre1, string nombre2, string apellido1, string apellido2, string cedula, string pais,
                              string correo, string telefono)
 {
     conexion      = new Conexion();
     empresaDAO    = new EmpresaDAO(conexion);
     representante = new Representante(id, nombre1, nombre2, apellido1, apellido2, cedula, pais, correo, telefono);
     empresa       = new Empresa(idE, nombreE, rucE, representante);
     empresaDAO.modificarEmpresa(empresa);
     //clienteDAO.modificarCliente(cliente);
 }
Ejemplo n.º 20
0
        //Persistir o objecto e salvar na base de dados
        private bool inserir(Representante ORepresentante)
        {
            ORepresentante.setDefaultInsertValues();
            ORepresentante.Pessoa.setDefaultInsertValues();

            db.Representante.Add(ORepresentante);
            db.SaveChanges();

            return(ORepresentante.id > 0);
        }
Ejemplo n.º 21
0
 public static RepresentanteDTO ConvertRepresentanteToDTO(Representante rep)
 {
     return(new RepresentanteDTO
     {
         RepresentanteCode = rep.RepresentanteCode,
         Name = rep.Name,
         Email = rep.Email,
         PhoneNumber = rep.PhoneNumber
     });
 }
Ejemplo n.º 22
0
        public ActionResult Eliminar(int cedula)
        {
            using (var db = new RepresentanteContext())
            {
                Representante rep = db.Representante.Find(cedula);
                db.Representante.Remove(rep);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
 public static Representante GuardarRepresentanteNegocio(Representante representante, int idPaciente)
 {
     if (representante.id == 0)
     {
         return(RepresentanteDatos.GuardarRepresentanteDatos(representante, idPaciente));
     }
     else
     {
         return(RepresentanteDatos.ModificarRepresentanteDatosDatos(representante, idPaciente));
     }
 }
Ejemplo n.º 24
0
        public void agregarEmpresa(string nombre1, string nombre2, string apellido1, string apellido2, string cedula, string pais,
                                   string correo, string telefono, string rucE, string nombreE)
        {
            cliente       = new Representante(0, nombre1, nombre2, apellido1, apellido2, cedula, pais, correo, telefono);
            empresa       = new Empresa(0, nombreE, rucE);
            conexion      = new Conexion();
            representante = new Representante(0, nombre1, nombre2, apellido1, apellido2, cedula, pais, correo, telefono);

            empresaDAO = new EmpresaDAO(conexion);
            empresaDAO.agregarEmpresa(representante, empresa);
        }
Ejemplo n.º 25
0
 public override void DesplegarDatos()
 {
     Console.WriteLine("\t*** Informacion de Persona Juridica ***");
     Console.WriteLine("\t\tIdentificacion: " + Identificacion);
     Console.WriteLine("\t\tFecha de constitucion: " + Fecha);
     Console.WriteLine("\t\tDireccion: " + Direccion);
     Console.WriteLine("\t\tRazon Social: " + RazonSocial);
     Console.WriteLine("\t\tTipo: " + Tipo.ToString());
     Console.WriteLine("\t\t * Representante Legal * ");
     Representante.DesplegarDatos();
 }
Ejemplo n.º 26
0
    public static void Main(string[] args)
    {
        Empreendedor  BBQ              = new Empreendedor("001", "BBQ", "127.576.567-08", "988484960", "Comercio");
        Empreendedor  Carlos           = new Empreendedor("002", "Carlos", "127.576.567-08", "995174985", "Industria");
        Representante MeuRepresentante = new Representante("9000", "Carlistor", "988020547");
        Empresa       MinhaEmpresa     = new Empresa("001", "FRICAO", "2730314512", "Comercio");
        Empresa       OutraEmpresa     = new Empresa("002", "RIGOCAO", "2730544512", "Industria");

        MinhaEmpresa.CadastrarEmpreendedor(BBQ);
        MinhaEmpresa.CadastrarEmpreendedor(Carlos);
        Carlos.SelecionarFornecedor();
    }
Ejemplo n.º 27
0
        /// <summary>
        /// Updates a representative information
        /// </summary>
        /// <param name="representative"></param>
        /// <returns></returns>
        public async Task <bool> UpdateRepresentative(Representante representative)
        {
            if (representative != null && representative.GetType().GetProperties()
                .All(p => p.GetValue(representative) != null))
            {
                _unitOfWork.RepresentativeRepository.Update(representative);
                await _unitOfWork.SaveChangesAsync();

                return(true);
            }
            throw new Exception();
        }
Ejemplo n.º 28
0
 //atualiza os dados do representante cadastrado
 public bool AtualizaRepresentante(Representante representante)
 {
     try{
         //update representante set nome = ?, uf = ?, ativo = ? where id = ?
         _context.representante.Update(representante);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception ex) {
         return(false);
     }
 }
Ejemplo n.º 29
0
        public ActionResult <string> PostRepresentante(Representante novoRepresentante)
        {
            bool resp = _representanteService.CadastrarRepresentante(novoRepresentante);

            if (resp)
            {
                return("Solicitação executada com sucesso!");
            }
            else
            {
                return("Falha ao executar a solicitação!");
            }
        }
Ejemplo n.º 30
0
        private void CarregaDadosRepresentante()
        {
            //Pega os dados do representante através do código na Sessão
            DataTable dtRepresentante = new Representante().Selecionar(Convert.ToInt64(Session["CdRepresentante"].ToString()));

            //Preenche os dados do usuário logado...
            if (dtRepresentante.Rows.Count > 0)
            {
                this.txtUserNome.Text   = dtRepresentante.Rows[0]["NOME"].ToString();
                this.txtUserEmail.Text  = dtRepresentante.Rows[0]["EMAIL"].ToString();
                this.txtUserPerfil.Text = dtRepresentante.Rows[0]["PERFIL"].ToString();
                this.txtUserDoc.Text    = dtRepresentante.Rows[0]["PESSOA"].ToString().Equals("F") ? dtRepresentante.Rows[0]["CPF"].ToString() : dtRepresentante.Rows[0]["CNPJ"].ToString();
            }
        }
        private string gerarLinhaExcel(Representante OItem)
        {
            StringBuilder linha = new StringBuilder();

            linha.Append(OItem.id).Append(";");
            linha.Append(OItem.Pessoa.nome).Append(";");
            linha.Append(OItem.Pessoa.profissao).Append(";");
            linha.Append(OItem.Pessoa.nroTelPrincipal + " | " + OItem.Pessoa.nroTelSecundario + " | " + OItem.Pessoa.nroTelTerciario).Append(";");
            linha.Append(OItem.Pessoa.emailPrincipal + " | " + OItem.Pessoa.emailSecundario).Append(";");
            linha.Append(OItem.Pessoa.enderecoWeb).Append(";");
            linha.Append(OItem.ativo == true ? "Sim" : "Não").Append(";");

            return(linha.ToString());
        }