Esempio n. 1
0
        public NotificationResult Excluir(int idFornecedor)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (idFornecedor == 0)
                {
                    return(notificationResult.Add(new NotificationError("Código do Fornecedor Inválido!")));
                }

                Fornecedor entidade = ListarUm(idFornecedor);

                if (entidade == null)
                {
                    return(notificationResult.Add(new NotificationError("Fornecedor não Encontrado!")));
                }

                if (notificationResult.IsValid)
                {
                    _fornecedorRepositorio.Remover(entidade);
                    notificationResult.Add("Fornecedor Removido com sucesso.");
                }

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 2
0
        public NotificationResult Salvar(Classe_Habilidade entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.CodClasse == 0)
                {
                    notificationResult.Add(new NotificationError("Cod Classe não pode ser zero.", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _classe_Habilidade_Repositorio.Adicionar(entidade);

                    notificationResult.Add("Classe Habilidade cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 3
0
        public NotificationResult Salvar(Ataque_Furtivo entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.CodNivel == 0)
                {
                    notificationResult.Add(new NotificationError("CodNivel não pode ser zero.", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _ataque_Furtivo_Repositorio.Adicionar(entidade);

                    notificationResult.Add("Ataque_Furtivo cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 4
0
        public async Task <NotificationResult> CreateShoplistWithIngredients(InsertShoplistWithIngredientsCommand command)
        {
            var result = new NotificationResult();
            var item   = new ShoplistInfo(command);

            result.Add(item.GetNotificationResult());
            if (!result.IsValid)
            {
                return(result);
            }
            result.Add(await _shoplistRepository.InsertAsync(item));
            if (result.IsValid)
            {
                result.Data = item.Id;

                /*
                 * foreach (var shoplistItem in command.ShoplistsIngredients)
                 * {
                 *  shoplistItem.SetId(item.Id.Value);
                 *  await _shoplistIngredientRepository.InsertAsync(shoplistItem);
                 * }*/

                result.AddMessage(Shared.Domain.Resources.Handler.InsertSuccess_Message);
            }
            else
            {
                result.AddErrorOnTop(Shared.Domain.Resources.Handler.InsertError_Message);
            }
            return(result);
        }
Esempio n. 5
0
        public NotificationResult Salvar(Ficha_Idioma entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.CodIdioma == 0)
                {
                    notificationResult.Add(new NotificationError("Cod Idioma não pode ser zero.", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _ficha_Idioma_Repositorio.Adicionar(entidade);

                    notificationResult.Add("Ficha Idioma cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
        public NotificationResult Salvar(ArmaduraInventario entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodJogador != 0 && entidade.CodFicha != 0 && entidade.CodArmadura != 0)
                {
                    entidade.CodJogador  = entidade.CodJogador;
                    entidade.CodFicha    = entidade.CodFicha;
                    entidade.CodArmadura = entidade.CodArmadura;

                    if (NotificationResult.IsValid)
                    {
                        _armaduraRepositorio.Adicionar(entidade);
                        NotificationResult.Add("Cadastrado!");
                    }

                    return(NotificationResult);
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("Erro no cadastro!", NotificationErrorType.USER)));
                };
            }

            catch (Exception ex)
            {
                return(NotificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 7
0
        public NotificationResult Excluir(int idVenda)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (idVenda <= 0)
                {
                    return(notificationResult.Add(new NotificationError("Código da Venda Inválido!")));
                }

                Venda entidade = ListarUm(idVenda);

                if (entidade == null)
                {
                    return(notificationResult.Add(new NotificationError("Venda não Encontrado!")));
                }

                if (notificationResult.IsValid)
                {
                    _vendaRepositorio.Remover(entidade);
                    notificationResult.Add("Venda Removida com sucesso.");
                }

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 8
0
        public NotificationResult Atualizar(Atributo entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodAtributo != 0)
                {
                    entidade.CodAtributo = entidade.CodAtributo;
                }

                if (NotificationResult.IsValid)
                {
                    _atributoServico.Atualizar(entidade);
                    NotificationResult.Add("Cadastro Alterado com Sucesso!");

                    return(NotificationResult);
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
                }
            }
            catch (Exception)
            {
                return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
            }
        }
Esempio n. 9
0
        public NotificationResult Excluir(Endereco entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.IdEndereco < 0)
                {
                    notificationResult.Add(new NotificationError("Endereco inválido."));
                }

                if (notificationResult.IsValid)
                {
                    _enderecoRepositorio.Remover(entidade);

                    notificationResult.Add("Endereco Removido com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 10
0
        public NotificationResult Excluir(Jogador entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodJogador != 0)
                {
                    if (NotificationResult.IsValid)
                    {
                        _jogadorRepositorio.Remover(entidade);
                        NotificationResult.Add("Cadastro excluido com Sucesso!");

                        return(NotificationResult);
                    }

                    else
                    {
                        return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
                    }
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
                }
            }

            catch (Exception ex)
            {
                return(NotificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 11
0
        public NotificationResult Salvar(Proficiencia_Teste_Resistencia entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.CodClasse == 0 || entidade.CodAtributo == 0)
                {
                    notificationResult.Add(new NotificationError("Qtde. de produtos no Estoque inválido.", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _proficiencia_Teste_Resistencia_Repositorio.Adicionar(entidade);

                    notificationResult.Add("Produto cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 12
0
        public virtual async Task <NotificationResult> InsertAsync(InsertRecipeCommand command)
        {
            var result = new NotificationResult();
            var item   = new RecipeInfo(command);

            result.Add(item.GetNotificationResult());
            if (!result.IsValid)
            {
                return(result);
            }
            result.Add(await _recipeRepository.InsertAsync(item));

            if (result.IsValid)
            {
                if (command.RecipeIngredients != null && command.RecipeIngredients.Count > 0)
                {
                    foreach (var recipeIngredientCommand in command.RecipeIngredients)
                    {
                        var recipeIngredient = new RecipeIngredientInfo(recipeIngredientCommand);
                        recipeIngredient.SetRecipeId(item.Id.Value);
                        result.Add(await _recipeIngredientRepository.InsertAsync(recipeIngredient));
                    }
                }

                result.Data = item.Id;
                result.AddMessage(Shared.Domain.Resources.Handler.InsertSuccess_Message);
            }
            else
            {
                result.AddErrorOnTop(Shared.Domain.Resources.Handler.InsertError_Message);
            }
            return(result);
        }
Esempio n. 13
0
        public NotificationResult Salvar(Jogador entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodJogador != 0)
                {
                    entidade.CodJogador = entidade.CodJogador;

                    if (NotificationResult.IsValid)
                    {
                        _jogadorRepositorio.Adicionar(entidade);
                        NotificationResult.Add("Cadastrado!");
                    }

                    return(NotificationResult);
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("Erro no cadastro!", NotificationErrorType.USER)));
                };
            }

            catch (Exception ex)
            {
                return(NotificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 14
0
        public NotificationResult Salvar(FichaAtributo entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodJogador != 0 && entidade.CodFicha != 0 && entidade.CodJogador != 0)
                {
                    entidade.CodJogador = entidade.CodJogador;
                    entidade.CodFicha   = entidade.CodFicha;
                    entidade.CodJogador = entidade.CodJogador;

                    if (NotificationResult.IsValid)
                    {
                        _fichaAtributoServico.Adicionar(entidade);
                        NotificationResult.Add("Cadastrado!");
                    }

                    return(NotificationResult);
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("Erro no cadastro!", NotificationErrorType.USER)));
                };
            }

            catch (Exception ex)
            {
                return(NotificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 15
0
        public NotificationResult Excluir(int idProduto)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (idProduto == 0)
                {
                    return(notificationResult.Add(new NotificationError("Código do Produto Inválido!")));
                }

                Produto entidade = ListarUm(idProduto);

                if (entidade == null)
                {
                    return(notificationResult.Add(new NotificationError("Produto não Encontrado!")));
                }

                if (notificationResult.IsValid)
                {
                    _produtoRepositorio.Remover(entidade);
                    notificationResult.Add("Produto Removido com sucesso.");
                }

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 16
0
        public NotificationResult Salvar(Inventario entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.CodFicha == 0 || entidade.CodJogador == 0)
                {
                    notificationResult.Add(new NotificationError("Qtde. de produtos no Estoque inválido.", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _inventario_Repositorio.Adicionar(entidade);

                    notificationResult.Add("Produto cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 17
0
        public NotificationResult Atualizar(Jogador entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodJogador != 0)
                {
                    entidade.CodJogador = entidade.CodJogador;
                }

                if (NotificationResult.IsValid)
                {
                    _jogadorRepositorio.Atualizar(entidade);
                    NotificationResult.Add("Cadastro Alterado com Sucesso!");

                    return(NotificationResult);
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
                }
            }
            catch (Exception)
            {
                return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
            }
        }
Esempio n. 18
0
        public NotificationResult Salvar(Endereco entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.IdEndereco < 0)
                {
                    notificationResult.Add(new NotificationError("Endereco inválido."));
                }

                if (notificationResult.IsValid)
                {
                    if (entidade.IdEndereco == 0)
                    {
                        _enderecoRepositorio.Adicionar(entidade);
                    }
                    else
                    {
                        _enderecoRepositorio.Atualizar(entidade);
                    }

                    notificationResult.Add("Endereco cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 19
0
        public NotificationResult Salvar(Dinheiro_Inventario entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.CodJogador == 0)
                {
                    notificationResult.Add(new NotificationError("Cod jogador não pode ser zero.", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _dinheiro_Inventario_Repositorio.Adicionar(entidade);

                    notificationResult.Add("Dinheiro Inventario cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 20
0
        public NotificationResult Atualizar(Cliente entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.idCliente <= 0)
                {
                    return(notificationResult.Add(new NotificationError("Código do Cliente Inválido!")));
                }

                if (EmailUtil.ValidarEmail(entidade.Email) == false)
                {
                    notificationResult.Add(new NotificationError("Email Inválido!", NotificationErrorType.USER));
                }

                if (CPFUtil.ValidarCPF(entidade.CPF) == false)
                {
                    notificationResult.Add(new NotificationError("CPF Do Cliente Inválido", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.TelefoneCelular))
                {
                    notificationResult.Add(new NotificationError("Telefone Inválido", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.Endereco))
                {
                    notificationResult.Add(new NotificationError("Endereço Informado Inválido", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.Nome))
                {
                    notificationResult.Add(new NotificationError("Nome Do Cliente Inválido", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.RG))
                {
                    notificationResult.Add(new NotificationError("RG Inválido", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.EnderecoImagem))
                {
                    notificationResult.Add(new NotificationError("Telefone Inválido", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _clienteRepositorio.Atualizar(entidade);
                    notificationResult.Add("Cliente Atualizado com sucesso.");
                }

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 21
0
        public NotificationResult Atualizar(Venda entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.idProduto <= 0)
                {
                    notificationResult.Add(new NotificationError("Codigo do Produto Invalido!", NotificationErrorType.USER));
                }

                if (entidade.idCliente <= 0)
                {
                    notificationResult.Add(new NotificationError("Código do Cliente Inválido!", NotificationErrorType.USER));
                }

                if (entidade.QtdVendida <= 0)
                {
                    notificationResult.Add(new NotificationError("Quantidade De Produtos Inválida!", NotificationErrorType.USER));
                }

                if (entidade.idVendedor <= 0)
                {
                    notificationResult.Add(new NotificationError("Código do Vendedor Inválido!", NotificationErrorType.USER));
                }

                if (entidade.ValorTotal <= 00.00)
                {
                    notificationResult.Add(new NotificationError("Valor Informado Inválido!", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.Descricao))
                {
                    notificationResult.Add(new NotificationError("Descrição de Venda Inválida!", NotificationErrorType.USER));
                }

                if (entidade.idVenda <= 0)
                {
                    return(notificationResult.Add(new NotificationError("Código da Venda Inválido!")));
                }

                if (string.IsNullOrEmpty(entidade.EnderecoImagem))
                {
                    notificationResult.Add(new NotificationError("URL da Imagem Inválida ou Não Suportada!", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _vendaRepositorio.Atualizar(entidade);
                    notificationResult.Add("Venda Atualizada com sucesso.");
                }

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 22
0
        public NotificationResult Salvar(DominioItem entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (NotificationResult.IsValid)
                {
                    _Item.Adicionar(entidade);
                    NotificationResult.Add("Item cadastrado com sucesso!");
                }

                return(NotificationResult);
            }

            catch (Exception ex)
            {
                return(NotificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 23
0
        public NotificationResult Salvar(Produto entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                entidade.DataCadastro = DateTime.Now;

                if (entidade.Estoque < 0)
                {
                    notificationResult.Add(new NotificationError("Qtde. de produtos no Estoque inválido.", NotificationErrorType.USER));
                }

                if (entidade.PrecoCusto <= 0)
                {
                    notificationResult.Add(new NotificationError("Preço de Custo inválido."));
                }

                if (notificationResult.IsValid)
                {
                    if (entidade.idProduto == 0)
                    {
                        _produtoRepositorio.Adicionar(entidade);
                    }
                    else
                    {
                        _produtoRepositorio.Atualizar(entidade);
                    }

                    notificationResult.Add("Produto cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
        public virtual async Task <NotificationResult> InsertAsync(InsertIngredientCommand command)
        {
            var result = new NotificationResult();
            var item   = new IngredientInfo(command);

            result.Add(item.GetNotificationResult());
            if (!result.IsValid)
            {
                return(result);
            }
            result.Add(await _ingredientRepository.InsertAsync(item));
            if (result.IsValid)
            {
                result.Data = item.Id;
                result.AddMessage(Shared.Domain.Resources.Handler.InsertSuccess_Message);
            }
            else
            {
                result.AddErrorOnTop(Shared.Domain.Resources.Handler.InsertError_Message);
            }
            return(result);
        }
Esempio n. 25
0
        public NotificationResult Atualizar(Produto entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.Valor <= 0)
                {
                    notificationResult.Add(new NotificationError("Valor Do Produto Inválido!", NotificationErrorType.USER));
                }

                if (entidade.Validade < DateTime.Now)
                {
                    notificationResult.Add(new NotificationError("Produto Está Vencido!", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.Nome))
                {
                    notificationResult.Add(new NotificationError("Nome Do Produto Inválido", NotificationErrorType.USER));
                }

                if (entidade.Quantidade <= 0)
                {
                    notificationResult.Add(new NotificationError("Quantidade de Produtos Inválida!", NotificationErrorType.USER));
                }

                if (entidade.idProduto <= 0)
                {
                    return(notificationResult.Add(new NotificationError("Código do Produto Inválido!")));
                }

                if (string.IsNullOrEmpty(entidade.EnderecoImagem))
                {
                    notificationResult.Add(new NotificationError("URL da Imagem Inválida ou Não Suportada!", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _produtoRepositorio.Atualizar(entidade);
                    notificationResult.Add("Produto Atualizado com sucesso.");
                }

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 26
0
        public NotificationResult Atualizar(Fornecedor entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (EmailUtil.ValidarEmail(entidade.Email) == false)
                {
                    notificationResult.Add(new NotificationError("Email Inválido!", NotificationErrorType.USER));
                }

                if (CNPJUtil.ValidarCNPJ(entidade.CNPJ) == false)
                {
                    notificationResult.Add(new NotificationError("CNPJ Do Fornecedor Inválido", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.TelefoneFixo))
                {
                    notificationResult.Add(new NotificationError("Telefone Inválido", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.Nome))
                {
                    notificationResult.Add(new NotificationError("Nome Do Fornecedor Inválido", NotificationErrorType.USER));
                }

                if (entidade.idFornecedor <= 0)
                {
                    return(notificationResult.Add(new NotificationError("Código do Fornecedor Inválido!")));
                }

                if (string.IsNullOrEmpty(entidade.EnderecoImagem))
                {
                    notificationResult.Add(new NotificationError("URL da Imagem Inválida ou Não Suportada!", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _fornecedorRepositorio.Atualizar(entidade);
                    notificationResult.Add("Fornecedor Atualizado com sucesso.");
                }

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
Esempio n. 27
0
        public virtual async Task <NotificationResult> UpdateAsync(UpdateRecipeCommand command)
        {
            var result = new NotificationResult();
            var item   = new RecipeInfo(command);

            result.Add(item.GetNotificationResult());
            if (!result.IsValid)
            {
                return(result);
            }
            result.Add(await _recipeRepository.UpdateAsync(item));
            if (result.IsValid)
            {
                result.Data = item.Id;
                result.AddMessage(Shared.Domain.Resources.Handler.UpdateSuccess_Message);
            }
            else
            {
                result.AddErrorOnTop(Shared.Domain.Resources.Handler.UpdateError_Message);
            }

            return(result);
        }
Esempio n. 28
0
        public NotificationResult Salvar(Estoque entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                if (entidade.Quantidade < 0)
                {
                    notificationResult.Add(new NotificationError("Qtde. de produtos no Estoque inválido.", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.Nome))
                {
                    notificationResult.Add(new NotificationError("Nome do Produto Inválido"));
                }

                if (string.IsNullOrEmpty(entidade.EnderecoImagem))
                {
                    notificationResult.Add(new NotificationError("Telefone Inválido", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _estoqueRepositorio.Adicionar(entidade);

                    notificationResult.Add("Produto cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }
        public virtual async Task <NotificationResult> DeleteByIdAsync(int id)
        {
            var result = new NotificationResult();

            result.Add(await _ingredientRepository.DeleteByIdAsync(id));
            if (result.IsValid)
            {
                result.AddMessage(Shared.Domain.Resources.Handler.DeleteSuccess_Message);
            }
            else
            {
                result.AddErrorOnTop(Shared.Domain.Resources.Handler.DeleteError_Message);
            }
            return(result);
        }
Esempio n. 30
0
        public NotificationResult Salvar(Produto entidade)
        {
            var notificationResult = new NotificationResult();

            try
            {
                entidade.DataEntrada = DateTime.Now;

                if (entidade.Valor <= 0)
                {
                    notificationResult.Add(new NotificationError("Valor Do Produto Inválido!", NotificationErrorType.USER));
                }

                if (entidade.Validade < DateTime.Today)
                {
                    notificationResult.Add(new NotificationError("Produto Está Vencido!", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.Nome))
                {
                    notificationResult.Add(new NotificationError("Nome Do Produto Inválido", NotificationErrorType.USER));
                }

                if (entidade.Quantidade <= 0)
                {
                    notificationResult.Add(new NotificationError("Quantidade Inválida de Produtos!", NotificationErrorType.USER));
                }

                if (string.IsNullOrEmpty(entidade.EnderecoImagem))
                {
                    notificationResult.Add(new NotificationError("URL da Imagem Inválida ou Não Suportada!", NotificationErrorType.USER));
                }

                if (notificationResult.IsValid)
                {
                    _produtoRepositorio.Adicionar(entidade);

                    notificationResult.Add("Produto cadastrado com sucesso.");
                }

                notificationResult.Result = entidade;

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(notificationResult.Add(new NotificationError(ex.Message)));
            }
        }