public async Task <IActionResult> SignIn([FromBody] KioskSignInDTO signIn) { var person = await _personRepo.Find(x => x.Id == signIn.PersonId); if (person.PersonType == PersonType.Teacher) { var teacherSession = new Session() { InTime = DateTime.Now, PersonId = signIn.PersonId, SemesterCode = _semesterRepo.GetAll().Last().Code }; var teacherResult = await _sessionRepo.Create(teacherSession); if (teacherResult is Session) { return(Created($"sessions/{teacherResult.Id}", teacherResult)); } throw new TCSException("Something went wrong"); } if (!signIn.Tutoring && signIn.SelectedReasons.Count() < 1) { throw new TCSException("Must select 1 or more reasons for visiting."); } var alreadySignedIn = await _sessionRepo.Exist(x => x.PersonId == signIn.PersonId && x.OutTime == null); if (alreadySignedIn) { throw new TCSException("You are already signed in."); } var session = new Session() { InTime = DateTime.Now, SessionClasses = signIn.SelectedClasses.Select(x => new SessionClass() { ClassId = x }).ToList(), SessionReasons = signIn.SelectedReasons.Select(x => new SessionReason() { ReasonId = x }).ToList(), PersonId = signIn.PersonId, SemesterCode = _semesterRepo.GetAll().Last().Code, Tutoring = signIn.Tutoring }; var result = await _sessionRepo.Create(session); if (result is Session) { return(Created($"sessions/{result.Id}", result)); } throw new TCSException("Something went wrong"); }