Example #1
0
        public ActionResult Create(ClienteViewModel objeto)
        {
            try
            {
                sv.Cadastrar(UsuarioLogado.IdEmpresa, objeto.Nome, objeto.DataNascimento, objeto.Telefone, objeto.Celular, objeto.Email, objeto.Sexo, objeto.OrigemSelecionada);

                TempData["Nome"] = objeto.Nome;
                TempData["Acao"] = "criado";

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);

                return(Create());
            }
        }
Example #2
0
        public void Cliente_CadastroQuandoClienteValido()
        {
            //-- Arrange
            OrigemModel origem = svOrigem.List(_empresa.Id).FirstOrDefault();

            //-- Action
            sv.Cadastrar(_empresa.Id, "Leonardo", new DateTime(1994, 5, 7), "(11) 97164-5267", "(11) 4555-1463", "*****@*****.**", "M", origem.Id);

            //-- Asserts
            ClienteModel c = sv.Find(_empresa.Id, "Leonardo");

            Assert.IsNotNull(c);
            Assert.AreEqual("Leonardo", c.Nome);
            Assert.AreEqual("(11) 97164-5267", c.Telefone);
            Assert.AreEqual("(11) 4555-1463", c.Celular);
            Assert.AreEqual("*****@*****.**", c.Email);
            Assert.AreEqual("M", c.Sexo);
            Assert.AreEqual(origem.Id, c.IdOrigem);
        }
Example #3
0
        public void SetupInicial(long idEmpresa)
        {
            try
            {
                try
                {
                    // Origem
                    _origemDomainServices.Cadastrar(idEmpresa, "Panfletagem");
                    _origemDomainServices.Cadastrar(idEmpresa, "Outdoors");
                }
                catch (DomainException dEx)
                {
                    Logger.Log.Warn(dEx);
                    throw;
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex);
                    throw;
                }

                try
                {
                    // Serviço
                    _servicoDomainServices.Cadastrar(idEmpresa, "Corte Feminino", 30, false);
                }
                catch (DomainException dEx)
                {
                    Logger.Log.Warn(dEx);
                    throw;
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex);
                    throw;
                }

                try
                {
                    // Produto
                    _produtoDomainServices.Cadastrar(idEmpresa, "Creme hidratante", 20);
                }
                catch (DomainException dEx)
                {
                    Logger.Log.Warn(dEx);
                    throw;
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex);
                    throw;
                }

                try
                {
                    // Cliente
                    long idOrigem = 0;
                    IEnumerable <OrigemModel> origens = _origemDomainServices.List(idEmpresa);
                    if (origens.IsNotNull() && origens.Count() > 0)
                    {
                        idOrigem = origens.FirstOrDefault().Id;
                    }

                    _clienteDomainServices.Cadastrar(idEmpresa, "Renata (Exemplo)", new DateTime(1991, 02, 05), null, "(11) 97164-5264", "*****@*****.**", "F", idOrigem);
                }
                catch (DomainException dEx)
                {
                    Logger.Log.Warn(dEx);
                    throw;
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex);
                    throw;
                }

                try
                {
                    // Funcionário
                    long idServico = 0;
                    IEnumerable <ServicoModel> origens = _servicoDomainServices.List(idEmpresa);
                    if (origens.IsNotNull() && origens.Count() > 0)
                    {
                        idServico = origens.FirstOrDefault().Id;
                    }

                    _funcionarioDomainServices.Cadastrar(idEmpresa, "Gustavo (Exemplo)", new DateTime(1985, 02, 05), "(11) 4665-5849", null, "*****@*****.**", "F", new long[] { idServico });
                }
                catch (DomainException dEx)
                {
                    Logger.Log.Warn(dEx);
                    throw;
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex);
                    throw;
                }
            }
            catch (DomainException)
            {
                //Logger.Log.Warn(dEx);
            }
            catch (Exception)
            {
                //Logger.Log.Error(ex);
            }
        }