Example #1
0
        public IComandResult Handle(AdicionarDepartamentoCommands comand)
        {
            //verificar se tem notificação no comand
            if (!comand.IsValid())
            {
                return(new ComandResult(false, "Por favor corrija os campos abaixo", comand.Notifications));
            }

            var escola = _repository.Existe(comand.EscolaId);

            if (escola != null)
            {
                foreach (var i in comand.DepartamentoId)
                {
                    var existe = _itemRepositorio.Existe(escola.Id, i.DepartamentoId);

                    if (existe == null)
                    {
                        var item = new ItemDepartamentoEscola(escola.Id, i.DepartamentoId);
                        _itemRepositorio.Salvar(item);
                    }
                }
            }
            else
            {
                return(new ComandResult(false, "Escola não encontrada,tente novamente!!", new { }));
            }

            return(new ComandResult(true, "Departamento adicionado com sucesso!!", new { }));
        }
Example #2
0
        public IComandResult Handle(SalvarItemDepartamentoEscolaCommands comand)
        {
            //verificar se tem notificação no comand
            if (!comand.IsValid())
            {
                return(new ComandResult(false, "Por favor corrija os campos abaixo", comand.Notifications));
            }

            var serie = new ItemDepartamentoEscola(comand.EscolaId, comand.DepartamentoId);

            _repository.Salvar(serie);

            return(new ComandResult(true, "Dados Salvos com Sucesso!!", new { }));
        }
Example #3
0
        public IComandResult Handle(SalvarEscolaCommands comand)
        {
            //verificar se tem notificação no comand
            if (!comand.IsValid())
            {
                return(new ComandResult(false, "Por favor corrija os campos abaixo", comand.Notifications));
            }

            var escola  = new Escola(comand.Nome.ToUpper(), comand.UsuarioId);
            var retorno = _repository.Salvar(escola);

            foreach (var i in comand.Item)
            {
                var existe = _itemRepositorio.Existe(retorno.Id, i.DepartamentoId);
                if (existe == null)
                {
                    var item = new ItemDepartamentoEscola(retorno.Id, i.DepartamentoId);
                    _itemRepositorio.Salvar(item);
                }
            }

            return(new ComandResult(true, "Dados Salvos com Sucesso!!", new { }));
        }
Example #4
0
 public void Alterar(ItemDepartamentoEscola obj)
 {
     _context.Entry <ItemDepartamentoEscola>(obj).State = EntityState.Modified;
 }
Example #5
0
        public ItemDepartamentoEscola Salvar(ItemDepartamentoEscola obj)
        {
            var retorno = _context.ItemDepartamentoEscolas.Add(obj);

            return(retorno.Entity);
        }