public ActionResult <StudentsReadDTO> GetSlotById(string id) { try { var student = repository.GetById(id); return(Ok(mapper.Map <StudentsReadDTO>(student))); } catch (System.Exception msg) { return(NotFound(msg)); } }
public async Task <IActionResult> Edit(int id) { var stud = await _studentsRepository.GetById(id); if (stud == null) { return(RedirectToAction("Index", "Students", new { error = "Студента не знайдено!" })); } StudentFormViewModel model = new StudentFormViewModel { LastName = stud.User.LastName, FirstName = stud.User.FirstName, MiddleName = stud.User.MiddleName, PhoneNumber = stud.User.PhoneNumber, University = stud.University, Faculty = stud.Faculty, Email = stud.User.Email, HasAccess = stud.HasAccess.Value, IsBan = stud.User.IsBanned.Value, Skills = stud.Skills, StudyYear = stud.StudyYear.HasValue ? stud.StudyYear.Value : 0 }; return(View(model)); }
// GET: StudentsController/Edit/5 public async Task <ActionResult> EditAsync(int id) { try { var result = await _studentsRepository.GetById(id); if (result.Item1) { var deps = _departamentsRepository.GetAll(); var statuses = _statusRepository.GetAll(); await Task.WhenAll(deps, statuses); ViewBag.DepartmentId = new SelectList(deps.Result.Item2, "Id", "DepartmentName", result.Item2.DepartmentId); ViewBag.StatusId = new SelectList(statuses.Result.Item2, "Id", "Name", result.Item2.StatusId); return(View(result.Item2)); } else { TempData["SuccessResultF"] = result.Item1; TempData["SuccessResultM"] = "Student not found"; return(RedirectToAction("Index", "Students")); } } catch (Exception) { throw; } }
public StudentsDetailsViewModel GetViewModel(int?studentId) { var student = repository.GetById(studentId); var a = new StudentsDetailsViewModel() { First = student.First, Middle = student.Middle, Last = student.Last, BirthDate = student.BirthDate, Sex = student.Sex, Rank = new Rank() { Id = student.RankId == 0?1: student.RankId, Name = student.RankName ?? "Без разряда" } }; return(a); }
public IActionResult GetStudentById(int id) { StudentEntity student = _studentsRepo.GetById(id); return(Ok(student)); }
public Student GetById(int id) { return(_repository.GetById(id)); }
public Student Get(int id) { return(studentsRepository.GetById(id)); }
public async Task <IActionResult> Get([FromRoute] int classId, [FromRoute] int studentId) { var student = await _repository.GetById(classId, studentId); return(Ok(student)); }