public void Produto_CadastroQuandoProdutoValido() { //-- Arrange string nomeProduto = "Produto Novo"; //-- Act sv.Cadastrar(_empresa.Id, nomeProduto, 25); //-- Asserts Assert.IsNotNull(sv.Find(_empresa.Id, nomeProduto)); Assert.IsNotNull(sv.List(_empresa.Id)); }
public ActionResult Create(ProdutoViewModel objeto) { try { sv.Cadastrar(UsuarioLogado.IdEmpresa, objeto.Nome, objeto.Preco); TempData["Nome"] = objeto.Nome; TempData["Acao"] = "criado"; return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View()); } }
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); } }