Exemplo n.º 1
0
        public IActionResult Mentor(BOMentorViewModel model)
        {
            if (!User.Identity.IsAuthenticated)
            {
                TempData["Got-Error"]     = "true";
                TempData["Login-Message"] = "É necessário iniciar sessão";

                return(RedirectToAction("Index", "Home"));
            }

            SchoolMentor mentor = new SchoolMentor
            {
                IdSchoolMentor = model.Mentor.IdSchoolMentor,
                Name           = model.Mentor.Name,
                Email          = model.Mentor.Email,
                ProjectAdvisor = model.Mentor.ProjectAdvisor
            };

            _context.SchoolMentor.Add(mentor);

            _context.SaveChanges();

            TempData["HasAlert"]     = "true";
            TempData["AlertMessage"] = "Mentor added successfully.";

            return(RedirectToAction("Mentors", "BackOffice"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the Mentors Main List Backoffice page
        /// </summary>
        /// <returns>Mentors Main List Backoffice page</returns>
        /// <remarks></remarks>
        public IActionResult Mentors()
        {
            if (!User.Identity.IsAuthenticated)
            {
                TempData["Got-Error"]     = "true";
                TempData["Login-Message"] = "É necessário iniciar sessão";

                return(RedirectToAction("Index", "Home"));
            }

            BOMentorViewModel viewModel = new BOMentorViewModel();
            var mentors = _context.SchoolMentor;

            viewModel.Mentors = mentors;

            return(View(viewModel));
        }
Exemplo n.º 3
0
        public IActionResult EditMentor(BOMentorViewModel model)
        {
            if (!User.Identity.IsAuthenticated)
            {
                TempData["Got-Error"]     = "true";
                TempData["Login-Message"] = "É necessário iniciar sessão";

                return(RedirectToAction("Index", "Home"));
            }

            _context.SchoolMentor.Update(model.Mentor);
            _context.SaveChanges();

            TempData["HasAlert"]     = "true";
            TempData["AlertMessage"] = "Mentor edited successfully.";

            return(RedirectToAction("Mentors", "BackOffice"));
        }