public ActionResult EditProblem([Bind(Include = "Trabalho_Id,Problema")] Trabalho trabalho) { TempData["item"] = "problema";// serve para voltar ao item do problema na ViewTrabalho1 if (ModelState.IsValid) { Trabalho trabalhoTemp = TempData["Trabalho"] as Trabalho; //busca trabalho aberto TempData["Trabalho"] = trabalhoTemp; //guarda trabalho aberto trabalho.Prof_Id = trabalhoTemp.Prof_Id; trabalho.Status = trabalhoTemp.Status; trabalho.Assunto = trabalhoTemp.Assunto; trabalho.Data_Inicio = trabalhoTemp.Data_Inicio; trabalho.Data_Tranca = trabalhoTemp.Data_Tranca; trabalho.Data_Fim = trabalhoTemp.Data_Fim; trabalho.Prof_Curso = trabalhoTemp.Prof_Curso; trabalho.Prof_Nome = trabalhoTemp.Prof_Nome; try { db.Entry(trabalho).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde"; return(View(trabalho)); } TempData["Trabalho"] = trabalho; return(RedirectToAction("ViewTrabalho1")); } ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde"; return(View(trabalho)); }
public async Task <IActionResult> Edit(int id, [Bind("TrabalhoId,Nome")] Trabalho trabalho) { if (id != trabalho.TrabalhoId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(trabalho); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrabalhoExists(trabalho.TrabalhoId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(trabalho)); }
public ActionResult Edit([Bind(Include = "Trabalho_Id,Assunto,Data_Inicio,Data_Tranca,Data_Fim,Status,Prof_Id")] Trabalho trabalho) { if (ModelState.IsValid) { Trabalho trabalhoTemp = TempData["Trabalho"] as Trabalho; //busca trabalho aberto TempData["Trabalho"] = trabalhoTemp; //guarda trabalho aberto trabalho.Problema = trabalhoTemp.Problema; trabalho.Prof_Curso = trabalhoTemp.Prof_Curso; trabalho.Prof_Nome = trabalhoTemp.Prof_Nome; trabalho.Prof_Id = trabalhoTemp.Prof_Id; trabalho.Status = trabalhoTemp.Status; try { db.Entry(trabalho).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { ViewData["Message"] = e; return(View(trabalho)); } TempData["Trabalho"] = trabalho; return(RedirectToAction("ViewTrabalho1")); } ViewData["Message"] = "Não foi possível salvar, tente novamente mais tarde"; return(View(trabalho)); }
public ActionResult EditarTrabalho(int id) { var trabalhosDAO = new TrabalhosDAO(); Trabalho trabalho = trabalhosDAO.BuscaPorId(id); return(View(trabalho)); }
public ActionResult Index(FormCollection form) { try { if (ModelState.IsValid == false) { return(Redirect("Trabalho/Index")); } var trabalho = TrabalhoRepository.recuperarPeloId(Int32.Parse(form["Id"])); if (trabalho == null) { trabalho = new Trabalho(); trabalho.Data = DateTime.Parse(form["Data"]); } trabalho.Jornada = TimeSpan.Parse(form["Jornada"]); TrabalhoRepository.salvar(trabalho); return(RedirectToAction("Index", "Trabalho").Mensagem("Trabalho Salvo com Sucesso!!!")); } catch (Exception e) { return(RedirectToAction("Index", "Trabalho").Mensagem("Ocorreu um erro inesperado. " + e.Message, "Erro")); } }
public void Remover(Trabalho trabalho) { int id = 0; contexto.Trabalhos.Where(c => c.Id == id).FirstOrDefault(); contexto.Trabalhos.Remove(trabalho); contexto.SaveChanges(); }
public async Task <IActionResult> Create([Bind("TrabalhoId,Nome")] Trabalho trabalho) { if (ModelState.IsValid) { _context.Add(trabalho); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(trabalho)); }
// GET: Trabalhoes/Create public ActionResult Create() { var prof = Session["prof"] as Professor;//busca professor logado Trabalho trabalho = new Trabalho(); trabalho.Prof_Id = prof.Prof_Id; trabalho.Data_Inicio = DateTime.Today.Date; trabalho.Data_Tranca = DateTime.Today.Date.AddDays(1); trabalho.Data_Fim = DateTime.Today.Date.AddDays(2); return(View(trabalho)); }
public static bool excluirPeloId(int id) { using (var db = new ContextoDB()) { var trabalho = new Trabalho { Id = id }; db.Trabalhos.Attach(trabalho); db.Entry(trabalho).State = EntityState.Deleted; db.SaveChanges(); return(true); } }
//-TRAB2 public static Home.Dashboard.TrabalhoDashboardVM ToTrabalhoDashboardVM(this Trabalho trabalho) { return(new Home.Dashboard.TrabalhoDashboardVM() { Aluno = trabalho.Aluno.ToAlunoVM(), AnoApresentacao = trabalho.Aluno.AnoApresentacao.ToString(), MesApresentacao = trabalho.Aluno.MesApresentacao.ToString(), DataCadastro = trabalho.DataCadastro, Id = trabalho.Id, Nome = trabalho.Nome, Orientador = trabalho.Orientador.ToOrientadorVM(), Turma = trabalho.Aluno.Turma.Codigo }); }
//--------------------------------------------------- // GET: Trabalhoes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { ViewData["Message"] = "Item não recebido"; } Trabalho trabalho = db.Trabalhoes.Find(id); if (trabalho == null) { ViewData["Message"] = "Item não encontrado"; } return(View(trabalho)); }
//Trabalho public static TrabalhoVM ToTrabalhoVM(this Trabalho trabalho) { return(new TrabalhoVM() { Aluno = trabalho.Aluno.ToAlunoVM(), Apresentacao = trabalho.Aluno.MesApresentacao + "/" + trabalho.Aluno.AnoApresentacao, Correcao = trabalho.Aluno.MesApresentacao + "/" + trabalho.Aluno.AnoApresentacao, DataCadastro = trabalho.DataCadastro, Id = trabalho.Id, Nome = trabalho.Nome, Orientador = trabalho.Orientador.ToOrientadorVM(), Turma = trabalho.Aluno.Turma.Codigo }); }
public ActionResult Create([Bind(Include = "Trabalho_Id,Assunto,Problema,Data_Inicio,Data_Tranca,Data_Fim,Status")] Trabalho trabalho) { if (ModelState.IsValid) { var prof = Session["prof"] as Professor;//busca professor logado trabalho.Prof_Id = prof.Prof_Id; Curso curso = db.Cursoes.Where(x => x.Curso_Id == prof.Curso_Id).FirstOrDefault(); trabalho.Prof_Curso = curso.Nome; trabalho.Prof_Nome = prof.Nome; trabalho.Status = "Planejamento"; //validação das datas if (trabalho.Data_Inicio < DateTime.Today.Date) { ViewData["data_inicio"] = "Data de início não pode ser anterior a data atual"; return(View(trabalho)); } else if (trabalho.Data_Tranca <= trabalho.Data_Inicio) { ViewData["data_tranca"] = "Data de execução não pode ser anterior ou igual a data de início"; return(View(trabalho)); } else if (trabalho.Data_Tranca >= trabalho.Data_Fim) { ViewData["data_tranca"] = "Data de execução não pode ser posterior ou igual a data fim"; return(View(trabalho)); } else if (trabalho.Data_Fim <= trabalho.Data_Tranca) { ViewData["data_fim"] = "Data fim não pode ser anterior ou igual a data de execução"; return(View(trabalho)); } try { db.Trabalhoes.Add(trabalho); db.SaveChanges(); TempData["Permissao"] = "Editar"; //dá permissão de editor para o autor do trabalho TempData["Trabalho"] = trabalho; //guarda trabalho aberto return(RedirectToAction("ViewTrabalho1")); } catch (Exception) { ViewData["Message"] = "Não foi possível salvar, tente novamente mais tarde"; return(View(trabalho)); } } ViewData["Message"] = "Não foi possível salvar, tente novamente mais tarde"; return(View(trabalho)); }
//-------------------------------------------------- // GET: Trabalhoes/Edit/5 public ActionResult EditProblem(int?id) //edição somente do problema do trabalho { TempData["item"] = "problema"; if (id == null) { ViewData["Message"] = "Item não recebido"; } Trabalho trabalho = db.Trabalhoes.Find(id); if (trabalho == null) { ViewData["Message"] = "Item não encontrado"; } TempData["Trabalho"] = trabalho; return(View(trabalho)); }
public ActionResult AdicionarTrabalho() { var aluno = new AlunosDAO(); var lista = aluno.ListarAlunos(); ViewBag.ListarAluno = lista; var disciplina = new DisciplinasDAO(); var listas = disciplina.ListarDisciplinas(); ViewBag.ListaDisciplina = listas; var trabalho = new Trabalho(); return(View(trabalho)); }
static void Main(string[] args) { Console.Write("Entre com o nome do departamento: "); string dep = Console.ReadLine(); Console.WriteLine("ENTRE COM OS DADOS DE TRABALHO"); Console.Write("Nome do funcionário: "); string nome = Console.ReadLine(); Console.Write("Nível de atuação (Junior/Medio/Senior): "); NivelTrabalho nivel = Enum.Parse <NivelTrabalho>(Console.ReadLine()); Console.Write("Entre com salário base: "); double salario = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.WriteLine(); //--------------------------------------------------------------------------------- Departamento departamento = new Departamento(dep); Trabalho trabalho = new Trabalho(nome, salario, nivel, departamento); //--------------------------------------------------------------------------------- Console.Write("Quantos contratos de trabalhos? "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Entre com os dados do contrato #{i}"); Console.Write("Data (dd/MM/aaaa): "); DateTime data = DateTime.Parse(Console.ReadLine()); Console.Write("Valor por hora: "); double valor = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Duração do trabalho em horas: "); int periodo = int.Parse(Console.ReadLine()); ContratoHoras contrato = new ContratoHoras(data, valor, periodo); trabalho.AddContrato(contrato); } Console.WriteLine(); Console.Write("Entre com o ano o mês para cálculo da renda: "); string mesAno = Console.ReadLine(); int mes = int.Parse(mesAno.Substring(0, 2)); int ano = int.Parse(mesAno.Substring(3)); Console.WriteLine("Nome: " + trabalho.Nome); Console.WriteLine("Departamento: " + trabalho.Departamento.Nome); Console.WriteLine("Renda para " + mesAno + " : " + trabalho.Renda(ano, mes).ToString("f2", CultureInfo.InvariantCulture)); }
// GET: Experiencias/Edit/5 public ActionResult Edit(int?id) { Trabalho trabalhoTemp = TempData["Trabalho"] as Trabalho; //busca trabalho aberto TempData["Trabalho"] = trabalhoTemp; //guarda trabalho aberto if (id == null) { ViewData["Message"] = "Item não recebido!"; } Avalia_Geral experiencia = db.Experiencias.Find(id); if (experiencia == null) { ViewData["Message"] = "Item não encontrado!"; } return(View(experiencia)); }
public TrabalhoViewModel(Trabalho entity) { this.Id = entity?.Id ?? 0; this.DataInsercao = entity?.DataInsercao ?? DateTime.Now; this.Empresa = entity?.Empresa; this.Contatos = entity?.Contatos?.Select(x => new TrabalhoContatoViewModel { Contato = new ContatoViewModel(x.Contato) }).ToList() ?? new List <TrabalhoContatoViewModel>(); this.Enderecos = entity?.Enderecos?.Select(x => new TrabalhoEnderecoViewModel { Endereco = new EnderecoViewModel(x.Endereco) }).ToList() ?? new List <TrabalhoEnderecoViewModel>(); this.Profissao = entity?.Profissao; this.Cargo = entity?.Cargo; this.Contato = this.Contatos?.FirstOrDefault()?.Contato ?? new ContatoViewModel(); this.Endereco = this.Enderecos?.FirstOrDefault()?.Endereco ?? new EnderecoViewModel(); }
public ActionResult Edit(long id) { Trabalho trabalhoSalvo = ObterListaTrabalhos() .Where(t => t.Id == id) .FirstOrDefault(); if (trabalhoSalvo == null) { return(RedirectToAction("404", "Erro")); } ViewBag.alunos = ObterListaAlunos() .ToAlunoVM(); ViewBag.orientadores = ObterListaOrientadores() .ToOrientadorVM(); return(View(trabalhoSalvo.ToTrabalhoVM())); }
public ActionResult Edit(TrabalhoVM trabRecebido, String descricaoAluno, String descricaoOrientador) { String matriculaAluno = descricaoAluno.Split(' ', '-', ' ').First(); String codigoOrientador = descricaoOrientador.Split(' ', '-', ' ').First(); Aluno alunoEscolhido = ObterListaAlunos() .Where(a => a.Matricula.Equals(matriculaAluno)) .FirstOrDefault(); Orientador orientadorEscolhido = ObterListaOrientadores() .Where(a => a.Codigo.Equals(codigoOrientador)) .FirstOrDefault(); if (alunoEscolhido == null || orientadorEscolhido == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } ModelState["Correcao"].Errors.Clear(); ModelState["Apresentacao"].Errors.Clear(); ModelState["Turma"].Errors.Clear(); if (ModelState.IsValid) { bool podeEditar = ObterListaTrabalhos() .Where(a => a.Id == trabRecebido.Id) .FirstOrDefault() != null; if (!podeEditar) { return(RedirectToAction("Unauthorized", "Erro")); } Trabalho novoTrabalho = trabRecebido.ToTrabalho(alunoEscolhido, orientadorEscolhido); Trabalho trabalhoSalvo = _trabalhoRepository.Find(novoTrabalho.Id); _trabalhoRepository.Update(trabalhoSalvo, novoTrabalho); return(RedirectToAction("Index")); } ViewBag.alunos = ObterListaAlunos() .ToAlunoVM(); ViewBag.orientadores = ObterListaOrientadores() .ToOrientadorVM(); return(View(trabRecebido)); }
public static int salvar(Trabalho trabalho) { using (var db = new ContextoDB()) { var trabalhoBd = recuperarPeloId(trabalho.Id); if (trabalhoBd == null) { db.Trabalhos.Add(trabalho); } else { db.Trabalhos.Attach(trabalho); db.Entry(trabalho).State = EntityState.Modified; } return(db.SaveChanges()); } }
public ActionResult Index(int?pagina, string sortOrder = "Dia", string searchString = null) { int numeroPagina = pagina ?? 1; int tamanhoPagina = 5; List <Trabalho> trabalhos = TrabalhoRepository.listaAll(); if (!String.IsNullOrEmpty(searchString)) { trabalhos = trabalhos.Where(t => t.Data.ToString().Contains(searchString) || t.Jornada.ToString().Contains(searchString) || t.Saldo.ToString().Contains(searchString)).ToList(); } switch (sortOrder) { case "Dia": trabalhos = trabalhos.OrderByDescending(t => t.Data).ToList(); break; case "Jornada": trabalhos = trabalhos.OrderBy(t => t.Jornada).ToList(); break; case "Saldo": trabalhos = trabalhos.OrderBy(t => t.Saldo).ToList(); break; default: trabalhos = trabalhos.OrderByDescending(t => t.Data).ToList(); break; } ViewBag.Trabalhos = trabalhos.ToPagedList(numeroPagina, tamanhoPagina); ViewBag.active = "Trabalho"; ViewBag.SaldoFormatado = DataUtil.formataHora(DataUtil.calculaSaldo(trabalhos.ToPagedList(numeroPagina, tamanhoPagina).ToList())); ViewBag.Saldo = DataUtil.calculaSaldo(trabalhos.ToPagedList(numeroPagina, tamanhoPagina).ToList()); ViewBag.Horas = DataUtil.formataHora(DataUtil.calculaHorasTrabalhadas(trabalhos.ToPagedList(numeroPagina, tamanhoPagina).ToList())); Trabalho trabalho = new Trabalho(); Ponto.isEntrada = false; return(View(trabalho)); }
// GET: trabalhoes/ViewTrabalho1 public ActionResult ViewExperiencias() { var prof = Session["prof"] as Professor; //busca professor logado Trabalho trabalhoTemp = TempData["Trabalho"] as Trabalho; //busca trabalho aberto TempData["Trabalho"] = trabalhoTemp; //guarda trabalho aberto ViewData["Titulo"] = trabalhoTemp.Assunto; TempData["Prof_Id"] = prof.Prof_Id; var experienciaUser = db.Experiencias.Where(x => x.Prof_Id == prof.Prof_Id).FirstOrDefault(); if (experienciaUser != null) { var experiencias = db.Experiencias.Where(x => x.Trabalho_Id == trabalhoTemp.Trabalho_Id); return(View(experiencias.ToList())); } else { return(RedirectToAction("ViewTrabalho1")); } }
public ActionResult Add(TrabalhoVM trabalhoRecebido, String descricaoAluno, String descricaoOrientador) { String matriculaAluno = descricaoAluno.Split(' ', '-', ' ').First(); String codigoOrientador = descricaoOrientador.Split(' ', '-', ' ').First(); Aluno alunoEscolhido = ObterListaAlunos() .Where(a => a.Matricula.Equals(matriculaAluno)) .FirstOrDefault(); Orientador orientadorEscolhido = ObterListaOrientadores() .Where(a => a.Codigo.Equals(codigoOrientador)) .FirstOrDefault(); if (alunoEscolhido == null || orientadorEscolhido == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } Trabalho novoTrabalho = trabalhoRecebido.ToTrabalho(alunoEscolhido, orientadorEscolhido); ModelState["Correcao"].Errors.Clear(); ModelState["Apresentacao"].Errors.Clear(); ModelState["Turma"].Errors.Clear(); if (ModelState.IsValid) { _trabalhoRepository.Persist(novoTrabalho); return(RedirectToAction("Index")); } List <AlunoVM> alunos = ObterListaAlunos().Where (a => a.Turma.Curso.Coordenador.Login.Equals(User.Identity.Name)) .ToAlunoVM() .ToList(); ViewBag.Orientadores = ObterListaOrientadores() .ToOrientadorVM(); ViewBag.Alunos = alunos; trabalhoRecebido.Aluno = alunoEscolhido.ToAlunoVM(); trabalhoRecebido.Orientador = orientadorEscolhido.ToOrientadorVM(); return(View(trabalhoRecebido)); }
public ActionResult VisualizarDetalhes(int id) { var alunos = new AlunosDAO(); var disciplinas = new DisciplinasDAO(); var trabalhosDAO = new TrabalhosDAO(); var trabalhos = trabalhosDAO.ListarTrabalhos(); foreach (var trabalhoo in trabalhos) { trabalhoo.Aluno = alunos.BuscaPorId(trabalhoo.AlunoId); } foreach (var trabalhoo in trabalhos) { trabalhoo.Disciplina = disciplinas.BuscaPorId(trabalhoo.DisciplinaId); } Trabalho trabalho = trabalhosDAO.BuscaPorId(id); return(View(trabalho)); }
private int[] ObterDataPrevistaApresentacao(Trabalho trab) { int ano = trab.Aluno.AnoIngresso; int semestre = trab.Aluno.MesIngresso; int semestresFaltando = (trab.Aluno.Turma.Curso.QtdSemestres - 1) + 1; while (semestresFaltando > 0) { if (semestre > 1) { ano++; semestre = 1; } else { semestre++; } semestresFaltando--; } return(new int[] { ano, semestre }); }
public ActionResult DetalheTrabalho(int id) { try { Trabalho trabalho = TrabalhoRepository.recuperarPeloId(id); List <Ponto> pontos = PontoRepository.listAllByTrabalho(id).OrderBy(x => x.Hora).ToList(); Ponto ponto = new Ponto(); ViewBag.Pontos = pontos; ViewBag.active = "Trabalho"; ViewBag.Ponto = ponto; Ponto.atualizaEntrada(pontos.Count > 0 ? pontos[pontos.Count - 1] : null); ponto.atualizaPonto(); trabalho.HorasTrabalho = DataUtil.calculaHorasTrabalho(pontos); trabalho.Saldo = DataUtil.calculaSaldo(trabalho); TrabalhoRepository.salvar(trabalho); return(View(trabalho)); } catch (Exception e) { return(RedirectToAction("index", "Trabalho").Mensagem("Ocorreu um erro inesperado. " + e.Message, "Erro")); } }
public void Seed() { if (_context.Curso.Any() || _context.Trabalho.Any()) { return; //BD populado } Trabalho t1 = new Trabalho(1, "Tese"); Trabalho t2 = new Trabalho(2, "Dissertação"); Trabalho t3 = new Trabalho(3, "TCC (Especialização)"); Trabalho t4 = new Trabalho(4, "TCC (Graduação)"); Curso c1 = new Curso(1, "Administração", "Universidade Federal de Mato Grosso, Faculdade de Administração e Ciências Contábeis, Cuiabá,", t3); Curso c2 = new Curso(2, "Ciência da Computação", "Universidade Federal de Mato Grosso, Instituto de Computação, Cuiabá,", t3); Curso c3 = new Curso(3, "Ciências da Saúde", "Universidade Federal de Mato Grosso, Faculdade de Ciências Médicas, Programa de Pós-Graduação em Ciências da Saúde, Cuiabá,", t1); _context.Trabalho.AddRange(t1, t2, t3, t4); _context.Curso.AddRange(c1, c2, c3); _context.SaveChanges(); }
public ActionResult EditarTrabalho([Bind(Include = "Id, AlunoId, Nota, DisciplinaId, , DataDeInicio, DataDaEntrega")] Trabalho trabalho) { trabalhosDAO = new TrabalhosDAO(); trabalhosDAO.Editar(trabalho); return(RedirectToAction("Index", "Trabalhos")); }
public ActionResult RemoverTrabalho(Trabalho trabalho) { trabalhosDAO.Remover(trabalho); return(RedirectToAction("Index", "Trabalhos")); }