示例#1
0
        public async Task <ActionResult <Student> > Get(Guid id)
        {
            var student = await _repository.GetStudentAsync(id);

            if (student != null)
            {
                return(Ok(student));
            }

            return(BadRequest(new { message = $"Студент не существует" }));
        }
示例#2
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            try
            {
                Student = await _repository.GetStudentAsync(id);

                return(Page());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(NotFound());
            }
        }
        public async Task <IActionResult> Get(int?id)
        {
            if (id == null)
            {
                return(BadRequest("invalid input data"));
            }

            Student student = await _studentsRepository.GetStudentAsync(id);

            if (student != null)
            {
                StudentDetailsViewModel studentDetailsVM = Mapper.Map <Student, StudentDetailsViewModel>(student);

                return(new OkObjectResult(studentDetailsVM));
            }
            else
            {
                return(NotFound("Could not find resource"));
            }
        }
示例#4
0
        public async Task <IActionResult> Get(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Student student = await _studentsRepository.GetStudentAsync(id);

            if (student != null)
            {
                StudentDetailsViewModel studentDetailsVM = Mapper.Map <Student, StudentDetailsViewModel>(student);

                return(new OkObjectResult(studentDetailsVM));
            }
            else
            {
                return(NotFound());
            }
        }
示例#5
0
        public async Task <IActionResult> GetStudentAsync(int studentId)
        {
            try
            {
                var student = await _studentsRepository.GetStudentAsync(studentId);

                if (student != null)
                {
                    return(new OkObjectResult(new StudentViewModel
                    {
                        // Id = student.StudentId,
                        Gender = student.Gender.Trim(),
                        Name = student.Name.Trim(),
                        SchoolId = student.School
                    }));
                }
                return(new NotFoundResult());
            }
            catch
            {
                return(new ConflictResult());
            }
        }
示例#6
0
        // GET: api/Student/5
        public async Task <Student.Data.Models.Student> GetAsync(Guid id)
        {
            var student = await studentsRepo.GetStudentAsync(id);

            return(student);
        }