public bool Insert(PlanejamentoModel planejamentoModel)
        {
            using (var transcaction = _context.Database.BeginTransaction())
            {
                try
                {
                    if (!(DateTime.Compare(planejamentoModel.DataFim, planejamentoModel.DataInicio) > 0) || TimeSpan.Compare(planejamentoModel.HorarioFim, planejamentoModel.HorarioInicio) != 1)
                    {
                        throw new ServiceException("Sua Datas ou Horarios possuem inconsistências, corrija-os e tente novamente.");
                    }

                    var planejamentoInserido = new Planejamento();
                    _context.Add(SetEntity(planejamentoModel, planejamentoInserido));
                    var save = _context.SaveChanges() == 1 ? true : false;

                    planejamentoModel.Id = planejamentoInserido.Id;

                    InsertReservasPlanejamento(planejamentoModel);

                    transcaction.Commit();
                    return(save);
                }
                catch (Exception e)
                {
                    transcaction.Rollback();
                    throw e;
                }
            }
        }
Esempio n. 2
0
        public PlanejamentoView Incluir(PlanejamentoView planejamentoView)
        {
            Planejamento planejamento = ObterModel(planejamentoView);

            repository.Incluir(planejamento);

            return(planejamento.ToView());
        }
Esempio n. 3
0
        public void Excluir(PlanejamentoView planejamentoView)
        {
            Planejamento planejamento = repository.ObterPorId(planejamentoView.Id);

            if (planejamento != null)
            {
                repository.Excluir(planejamento);
            }
        }
    void Start()
    {
        planejamento = FindObjectOfType <Planejamento>();

        ZerarMidiasPadraoDoProfessor();

        ConfigurarPlanejamento(CustomGameSettings.CurrentSettings);

        BloquearPlanejamentoAteFalarComProfessor();
    }
Esempio n. 5
0
        public void Dado_um_novo_planejamento_valido_ele_deve_gerar_um_numero_com_8_caracteres()
        {
            Procedimento  _procedimento = new Procedimento("TEADF", 12, AreaNegocio.Flexivel, true);
            Objeto        _objeto       = new Objeto(AreaNegocio.Flexivel, "TR500101");
            List <Objeto> _objetos      = new List <Objeto>();

            _objetos.Add(_objeto);

            var planejamento = new Planejamento(_objetos, _procedimento, new DateTime(2018, 01, 15), new Periodicidade(12));

            Assert.AreEqual(36, planejamento.Id.ToString().Length);
        }
 public static PlanejamentoView ToView(this Planejamento model)
 {
     return(new PlanejamentoView
     {
         Id = model.Id,
         Meta = model.Meta,
         DataInicial = model.DataInicial,
         DataFinal = model.DataFinal,
         Valor = model.Valor,
         EtiquetaId = model.EtiquetaId,
         Tipo = model.Tipo.TipoPlanejamentoParaString()
     });
 }
        private static Planejamento SetEntity(PlanejamentoModel model, Planejamento entity)
        {
            entity.Id            = model.Id;
            entity.DataInicio    = model.DataInicio;
            entity.DataFim       = model.DataFim;
            entity.HorarioInicio = model.HorarioInicio;
            entity.HorarioFim    = model.HorarioFim;
            entity.DiaSemana     = model.DiaSemana;
            entity.Objetivo      = model.Objetivo;
            entity.Sala          = model.SalaId;
            entity.Usuario       = model.UsuarioId;


            return(entity);
        }
Esempio n. 8
0
 public static Planejamento GetPlanejamentoCategoriaByMesEAno(Usuario usuario, Categoria categoria, int mes, int ano)
 {
     try
     {
         // Verifica se existe um planejamento do usuário para a categoria, o mês e o ano fornecidos:
         connection.OpenConnection();
         Planejamento planejamento = connection.context.Planejamentos.FirstOrDefault(x => x.IdUsuario == usuario.IdUsuario && x.IdCategoria == categoria.IdCategoria && x.Mes == mes && x.Ano == ano);
         connection.CloseConnection();
         return(planejamento);
     }
     catch (Exception ex)
     {
         connection.CloseConnection();
         throw ex;
     }
 }
Esempio n. 9
0
 public static Planejamento GetPlanejamentoById(Guid idPlanejamento)
 {
     try
     {
         // Verifica se existe um planejamento com o id fornecido:
         connection.OpenConnection();
         Planejamento planejamento = connection.context.Planejamentos.FirstOrDefault(x => x.IdPlanejamento.Equals(idPlanejamento));
         connection.CloseConnection();
         return(planejamento);
     }
     catch (Exception ex)
     {
         connection.CloseConnection();
         throw ex;
     }
 }
Esempio n. 10
0
 public static void SavePlanejamento(Planejamento planejamento)
 {
     try
     {
         // A aplicação salva o planejamento substituindo o anterior, caso exista:
         Planejamento old = GetPlanejamentoCategoriaByMesEAno(UsuarioManager.GetUsuarioById(planejamento.IdUsuario), CategoriaManager.GetCategoriaById(planejamento.IdCategoria), planejamento.Mes, planejamento.Ano);
         if (old == null)
         {
             planejamento.IdPlanejamento = Guid.NewGuid();
             AddPlanejamento(planejamento);
         }
         else
         {
             planejamento.IdPlanejamento = old.IdPlanejamento;
             EditPlanejamento(planejamento);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 11
0
 public static void AddPlanejamento(Planejamento planejamento)
 {
     try
     {
         // A aplicação gera um novo planejamento com as definições padrões:
         ValidarDadosPlanejamento(planejamento);
         if (planejamento.IdPlanejamento == Guid.Empty)
         {
             planejamento.IdPlanejamento = Guid.NewGuid();
         }
         planejamento.DataAtualizacao = DateTime.UtcNow.AddHours(-3);
         connection.OpenConnection();
         connection.context.Entry(planejamento).State = EntityState.Added;
         connection.context.SaveChanges();
         connection.CloseConnection();
     }
     catch (Exception ex)
     {
         connection.CloseConnection();
         throw ex;
     }
 }
Esempio n. 12
0
        private static void ValidarDadosPlanejamento(Planejamento planejamento)
        {
            if (UsuarioManager.GetUsuarioById(planejamento.IdUsuario) == null)
            {
                throw new PlanejamentoUsuarioException("Não foi possível salvar o planejamento com o usuário informado.");
            }

            if (CategoriaManager.GetCategoriaById(planejamento.IdCategoria) == null)
            {
                throw new PlanejamentoCategoriaException("Não foi possível salvar o planejamento com a categoria informada.");
            }

            if (planejamento.Mes < 1 || planejamento.Mes > 12)
            {
                throw new PlanejamentoMesException("O mês fornecido não é válido.");
            }

            if (planejamento.Valor <= 0)
            {
                throw new PlanejamentoValorException("O valor deve ser preenchido com um número decimal positivo.");
            }
        }
Esempio n. 13
0
        public static void DeletePlanejamento(Planejamento planejamento)
        {
            try
            {
                // A aplicação remove o planejamento fornecido:
                Planejamento old = GetPlanejamentoById(planejamento.IdPlanejamento);
                if (old == null)
                {
                    throw new Exception("Planejamento não encontrado no sistema.");
                }

                connection.OpenConnection();
                connection.context.Entry(planejamento).State = EntityState.Deleted;
                connection.context.SaveChanges();
                connection.CloseConnection();
            }
            catch (Exception ex)
            {
                connection.CloseConnection();
                throw ex;
            }
        }
Esempio n. 14
0
        public static List <GridRowPlanejamento> GetRowPlanejamentos(Usuario usuario, int mes, int ano)
        {
            try
            {
                List <GridRowPlanejamento> planejamentos = new List <GridRowPlanejamento>();
                List <Transacao>           transacoes    = TransacaoManager.GetTransacoesEfetuadas(usuario, mes, ano);

                foreach (Categoria categoria in CategoriaManager.GetCategorias().OrderByDescending(x => x.Nome).OrderBy(x => x.TipoFluxo))
                {
                    Decimal?     valorEfetivo = transacoes.Where(x => x.IdCategoria == categoria.IdCategoria).Sum(x => x.Valor);
                    Planejamento planejamento = GetPlanejamentoCategoriaByMesEAno(usuario, categoria, mes, ano);

                    if (valorEfetivo > 0 || planejamento != null)
                    {
                        planejamentos.Add(new GridRowPlanejamento
                        {
                            IdPlanejamento     = planejamento == null ? Guid.NewGuid() : planejamento.IdPlanejamento,
                            IdCategoria        = categoria.IdCategoria,
                            Categoria          = categoria.Nome,
                            DescricaoCategoria = categoria.Descricao,
                            IconeCategoria     = "Images/Categorias/" + categoria.Icone,
                            TipoFluxo          = categoria.TipoFluxo,
                            Mes            = mes,
                            Ano            = ano,
                            ValorRealizado = valorEfetivo != null ? (Decimal)valorEfetivo : 0,
                            ValorPlanejado = planejamento != null ? planejamento.Valor : 0
                        });
                    }
                }
                return(planejamentos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 15
0
        public static void EditPlanejamento(Planejamento planejamento)
        {
            try
            {
                // A aplicação atualiza os dados do planejamento fornecido:
                Planejamento old = GetPlanejamentoById(planejamento.IdPlanejamento);
                if (old == null)
                {
                    throw new Exception("Planejamento não encontrado no sistema.");
                }

                ValidarDadosPlanejamento(planejamento);
                planejamento.DataAtualizacao = DateTime.UtcNow.AddHours(-3);
                connection.OpenConnection();
                connection.context.Entry(planejamento).State = EntityState.Modified;
                connection.context.SaveChanges();
                connection.CloseConnection();
            }
            catch (Exception ex)
            {
                connection.CloseConnection();
                throw ex;
            }
        }
    protected override IEnumerator Start()
    {
        yield return(base.Start());

        planejamento = GetComponentInParent <Planejamento>();
    }
Esempio n. 17
0
 public void Save(Planejamento plan)
 {
 }
Esempio n. 18
0
        //_objetos.Add(_objeto);

        public Planejamento Get(Guid Id)
        {
            var planejamento = new Planejamento(_objetos, _procedimento, new DateTime(2018, 01, 15), new Periodicidade(12));

            return(planejamento);
        }