Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,Codigo,Data,Validade,Desconto,Utilizado")] Cupom cupom)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cupom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cupom));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,Titulo,CabecalhoTexto1_Index,Texto1_Index,Logo,NotaDeCorte,Video_Index,CabecalhoTexto2_Index,Texto2_Index,CabecalhoTexto3_Index,Texto3_Index,TextoAlvo_Index,TextoGrafico_Index,TextoComputador_Index,EnderecoLinha1,EnderecoLinha2,EnderecoLinha3")] Configuracao configuracao)
        {
            if (ModelState.IsValid)
            {
                _context.Add(configuracao);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(configuracao));
        }
        public async Task <IActionResult> Create([Bind("Id,AvaliacaoId,Descricao")] PerguntaAvaliacao perguntaAvaliacao)
        {
            if (ModelState.IsValid)
            {
                _dbContext.Add(perguntaAvaliacao);
                await _dbContext.SaveChangesAsync();

                return(RedirectToAction("Index", "Avaliacoes", new { perguntaId = perguntaAvaliacao.Id }));
            }
            return(View(perguntaAvaliacao));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Id,Descricao,Valor")] Desconto desconto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(desconto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(desconto));
        }
Пример #5
0
        public async Task <IActionResult> Create([Bind("Id,Nome,Descricao,Preco")] Curso curso)
        {
            if (ModelState.IsValid)
            {
                _context.Add(curso);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(curso));
        }
Пример #6
0
        public async Task <IActionResult> Create([Bind("Id,UserId,NotaQuestionario,Nome,Email,WhatsApp")] Aluno aluno)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aluno);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(aluno));
        }
Пример #7
0
        public async Task <IActionResult> Create([Bind("Id,CursoId,AlunoId,Liberado,Data")] Matricula matricula)
        {
            if (ModelState.IsValid)
            {
                _context.Add(matricula);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AlunoId"] = new SelectList(_context.Alunos, "Id", "Id", matricula.AlunoId);
            ViewData["CursoId"] = new SelectList(_context.Cursos, "Id", "Id", matricula.CursoId);
            return(View(matricula));
        }
        public async Task <IActionResult> Create([Bind("Id,Descricao")] PerguntaQuestionario perguntaQuestionario)
        {
            if (ModelState.IsValid)
            {
                // Só há um questionário
                perguntaQuestionario.QuestionarioId = 1;

                _context.Add(perguntaQuestionario);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(perguntaQuestionario));
        }
        public async Task <IActionResult> Create([Bind("Id,PerguntaAvaliacaoId,Descricao,Correta,Escolhida")] RespostaAvaliacao respostaAvaliacao)
        {
            if (ModelState.IsValid)
            {
                _context.Add(respostaAvaliacao);

                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                PerguntaAvaliacao perguntaAvaliacao = await _context.PerguntasAvaliacao.FirstOrDefaultAsync(a => a.Id == respostaAvaliacao.PerguntaAvaliacaoId);

                return(RedirectToAction("Index", "Avaliacoes", new { id = perguntaAvaliacao.AvaliacaoId, perguntaId = respostaAvaliacao.PerguntaAvaliacaoId }));
            }
            ViewData["PerguntaAvaliacaoId"] = new SelectList(_context.PerguntasAvaliacao, "Id", "Id", respostaAvaliacao.PerguntaAvaliacaoId);
            return(View(respostaAvaliacao));
        }
Пример #10
0
        public async Task <IActionResult> Create([Bind("Id,ModuloId,Descricao")] Avaliacao avaliacao)
        {
            if (ModelState.IsValid)
            {
                _context.Add(avaliacao);
                await _context.SaveChangesAsync();

                var modulo = await _context.Modulos.FindAsync(avaliacao.ModuloId);

                modulo.AvaliacaoId = avaliacao.Id;
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(avaliacao));
        }
Пример #11
0
        public async Task <IActionResult> Create([Bind("Id,CursoId,Descricao")] Modulo modulo)
        {
            if (ModelState.IsValid)
            {
                var seq = await _context.Modulos.Where(m => m.CursoId == modulo.CursoId).OrderByDescending(m => m.NumeroModulo).FirstOrDefaultAsync();

                if (seq == null)
                {
                    modulo.NumeroModulo = 1;
                }
                else
                {
                    modulo.NumeroModulo = seq.NumeroModulo + 1;
                }

                _context.Add(modulo);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Cursos", new { id = modulo.CursoId, moduloId = modulo.Id }));
            }
            ViewData["CursoId"] = new SelectList(_context.Cursos, "Id", "Id", modulo.CursoId);
            return(View(modulo));
        }
Пример #12
0
        public async Task <IActionResult> Create([Bind("Id,ModuloId,NumeroAula,Descricao,Video,MaterialApoio,ArquivosApoio")] Aula aula)
        {
            if (ModelState.IsValid)
            {
                var seq = await _context.Aulas.Where(a => a.ModuloId == aula.ModuloId).OrderByDescending(a => a.NumeroAula).FirstOrDefaultAsync();


                if (aula.Video != null && aula.Video.Contains("https://youtu.be/"))
                {
                    string newPath = aula.Video.Replace("https://youtu.be/", "https://www.youtube.com/watch?v=");

                    aula.Video = newPath;
                }

                if (seq == null)
                {
                    aula.NumeroAula = 1;
                }
                else
                {
                    aula.NumeroAula = seq.NumeroAula + 1;
                }

                aula.Modulo = null;

                _context.Add(aula);

                await _context.SaveChangesAsync();

                Modulo modulo = _context.Modulos.Find(aula.ModuloId);
                return(RedirectToAction("Index", "Cursos", new { id = modulo.CursoId, moduloId = aula.ModuloId }));
            }
            ViewData["CursoId"]  = new SelectList(_context.Cursos, "Id", "Nome");
            ViewData["ModuloId"] = new SelectList(_context.Modulos, "Id", "Descricao", aula.ModuloId);
            return(View(aula));
        }