Пример #1
0
        public void Origem_CadastroQuandoOrigemValido()
        {
            //-- Arrange

            string nomeOrigem = "Nova Origem";

            //-- Act
            sv.Cadastrar(_empresa.Id, nomeOrigem);

            //-- Asserts
            OrigemModel o = sv.Find(_empresa.Id, nomeOrigem);

            Assert.IsNotNull(o);
            Assert.AreEqual(nomeOrigem, o.Nome);
            Assert.IsNotNull(sv.List(_empresa.Id));
        }
Пример #2
0
        public ActionResult Create(OrigemViewModel objeto)
        {
            try
            {
                sv.Cadastrar(UsuarioLogado.IdEmpresa, objeto.Nome);

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

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