Example #1
0
        // GET: StudentsController
        public async Task <ActionResult> IndexAsync()
        {
            try
            {
                var result = await _studentsRepository.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> 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;
            }
        }
        public async Task <IActionResult> Get()
        {
            var pagination = Request.Headers["Pagination"];

            if (!string.IsNullOrEmpty(pagination))
            {
                string[] vals = pagination.ToString().Split(',');
                int.TryParse(vals[0], out page);
                int.TryParse(vals[1], out pageSize);
            }

            int currentPage     = page;
            int currentPageSize = pageSize;
            var totalStudents   = await _studentsRepository.CountAsync();

            var totalPages = (int)Math.Ceiling((double)totalStudents / pageSize);

            IEnumerable <Student> students = _studentsRepository
                                             .GetAll()
                                             .OrderBy(s => s.ID)
                                             .Skip((currentPage - 1) * currentPageSize)
                                             .Take(currentPageSize)
                                             .ToList();

            Response.AddPagination(page, pageSize, totalStudents, totalPages);

            IEnumerable <StudentViewModel> studentsVM = Mapper.Map <IEnumerable <Student>, IEnumerable <StudentViewModel> >(students);

            return(new OkObjectResult(studentsVM));
        }
        public async Task <IActionResult> GetStudentsAsync()
        {
            //return await _context.GetAll();
            var studentItems = await _context.GetAll();

            return(Ok(_mapper.Map <IEnumerable <ReadStudentDto> >(studentItems)));
        }
Example #5
0
 public List <Student> GetAllStudents()
 {
     using (Db.BeginReadOnlyWork())
     {
         return(_studentsRepository.GetAll());
     }
 }
        public async Task <IActionResult> GetStudentsAsync()
        {
            //return await _context.GetAll();
            var studentItems = await _context.GetAll();

            _log.AddLog(Request, _httpContextAccessor, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), "Eshte nxjerrur lista e studenteve");
            return(Ok(_mapper.Map <IEnumerable <ReadStudentDTO> >(studentItems)));
        }
Example #7
0
 public ActionResult <Dictionary <string, IEnumerable <Students> > > GetAllStudents()
 {
     try
     {
         var list = repository.GetAll();
         Dictionary <string, IEnumerable <Students> > result = new Dictionary <string, IEnumerable <Students> >();
         result.Add("Students", list);
         return(Ok(result));
     }
     catch (System.Exception msg)
     {
         return(NotFound(msg));
     }
 }
 // GET: Students
 public async Task <IActionResult> Index()
 {
     return(View(await _studentsRepository.GetAll()));
 }
 public async Task <IEnumerable <Students> > GetAll()
 {
     return(await _studentsRepository.GetAll());
 }
        public IActionResult GetAllStudents()
        {
            List <StudentEntity> students = _studentsRepo.GetAll();

            return(Ok(students));
        }
 public async Task <ActionResult <IEnumerable <Student> > > GetStudents()
 {
     return(Ok(await _repo.GetAll()));
 }
 public IEnumerable <Student> Get()
 {
     return(studentsRepository.GetAll());
 }
        public async Task <IActionResult> Get([FromRoute] int classId)
        {
            var students = await _repository.GetAll(classId);

            return(Ok(students));
        }