public void Funcionario_CadastroQuandoFuncionarioValido()
        {
            //-- Arrange
            ServicoModel s = svServico.List(_empresa.Id).FirstOrDefault();

            //-- Action
            Guid guid = Guid.NewGuid();

            sv.Cadastrar(_empresa.Id, "Leonardo", new DateTime(1994, 5, 7), "(11) 4555-1463", "(11) 97164-5267", "*****@*****.**", "M", new long[] { s.Id });

            //-- Asserts
            FuncionarioModel f = sv.Find(_empresa.Id, "Leonardo");

            Assert.IsNotNull(f);
            Assert.AreEqual("Leonardo", f.Nome);
            Assert.AreEqual("(11) 4555-1463", f.Telefone);
            Assert.AreEqual("(11) 97164-5267", f.Celular);
            Assert.AreEqual("*****@*****.**", f.Email);
            Assert.AreEqual("M", f.Sexo);
            //Assert.IsNotNull(f.Servicos);
            //Assert.IsNotNull(f.Servicos.Where(x => x.Id == s.Id).FirstOrDefault());
        }
Beispiel #2
0
        public ActionResult Create(FuncionarioViewModel objeto)
        {
            try
            {
                sv.Cadastrar(UsuarioLogado.IdEmpresa,
                             objeto.Nome,
                             objeto.DataNascimento,
                             objeto.Telefone,
                             objeto.Celular,
                             objeto.Email,
                             objeto.Sexo,
                             objeto.ServicosSelecionados);

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

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(Create());
            }
        }
        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);
            }
        }