public async Task <IActionResult> AddAsync()
        {
            try
            {
                var professors = _professorsRepository.GetAll();
                var students   = _studentsRepository.GetAll();
                var subjects   = _subjectsRepository.GetAll();

                await Task.WhenAll(professors, students, subjects);

                if (professors.Result.Item1)
                {
                    ViewBag.ProfessorId = new SelectList(professors.Result.Item2, "Id", "ProfessorName");
                    ViewBag.StudentId   = new SelectList(students.Result.Item2, "Id", "Name");
                    ViewBag.SubjectId   = new SelectList(subjects.Result.Item2, "Id", "SubjectName");
                    return(View());
                }
                else
                {
                    TempData["SuccessResultF"] = false;
                    TempData["SuccessResultM"] = "You are not logged in!";
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public async Task <IActionResult> GetProfessorsAsync()
        {
            var professorItems = await _context.GetAll();

            _log.AddLog(Request, _httpContextAccessor, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), "Eshte nxjerrur lista e profesoreve");
            return(Ok(_mapper.Map <IEnumerable <ReadProffesorDTO> >(professorItems)));
        }
Example #3
0
        public async Task <ActionResult> IndexAsync()
        {
            try
            {
                var result = await _professorsRepository.GetAll();

                if (result.Item1)
                {
                    if (TempData["SuccessResultF"] != null)
                    {
                        ViewBag.Notification = new SuccessResult((bool)TempData["SuccessResultF"], (string)TempData["SuccessResultM"]);
                    }
                    return(View(result.Item2));
                }
                else
                {
                    TempData["SuccessResultF"] = false;
                    TempData["SuccessResultM"] = "You are not logged in!";
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> GetProfessorsAsync()
        {
            var professorItems = await _context.GetAll();

            return(Ok(_mapper.Map <IEnumerable <ReadProfessorDto> >(professorItems)));
        }
Example #5
0
 public List <Professor> GetProfessors()
 {
     return(repository.GetAll());
 }