public async Task <IActionResult> ClockIn(string moniker) { try { //find jobsite var jobsite = await _repository.GetJobsiteAsync(moniker); if (jobsite == null) { return(NotFound()); } //get current user var user = await _userRepository.GetUser(_userAccessor.GetCurrentUsername()); //if already clocked in, bad request var currentlyClockedin = await _timestampRepository.GetClockedInTimestamp(user); if (currentlyClockedin != null) { return(BadRequest($"Already clocked in at {currentlyClockedin.Jobsite.Moniker}")); } //clock in if (await _timestampRepository.ClockIn(jobsite, user)) { return(Ok("Clocked in Successfully.")); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Server Error: Failed to clock in")); } return(BadRequest()); }