public IActionResult ClockIn(bool In, ClockInViewModel model) { if (ModelState.IsValid) { if (model.OnClock && In) { ViewData["Info"] = "Currently Clocked In, clock out"; return(View(model)); } if (!model.OnClock && In) { var clockIn = new ClockIn { ClockInTime = DateTime.Now, TimeSheetId = model.TimeSheetId }; _context.ClockIns.Add(clockIn); _context.SaveChanges(); return(RedirectToAction("Index", new { In = true, Time = clockIn.ClockInTime })); } if (model.OnClock && !In) { var clockIn = _context.ClockIns.Last(x => x.TimeSheetId == model.TimeSheetId && x.ClockOutTime == null); clockIn.ClockOutTime = DateTime.Now; _context.ClockIns.Update(clockIn); _context.SaveChanges(); return(RedirectToAction("Index", new { In = false, Time = clockIn.ClockOutTime })); } } return(View(model)); }
public IActionResult ClockIn() { if (User.IsInRole("Administrator") || User.IsInRole("Payroll")) { return(RedirectToAction("Index", "Home")); } var user = _userManager.FindByNameAsync(User.Identity.Name).GetAwaiter().GetResult(); var timeSheet = FindTimeSheet(user.Id); ClockIn clockIn = null; if (_context.ClockIns.Any(x => x.TimeSheetId == timeSheet.Id)) { if (_context.ClockIns.Any(x => x.TimeSheetId == timeSheet.Id && x.ClockOutTime == null)) { clockIn = _context.ClockIns.Last(x => x.TimeSheetId == timeSheet.Id && x.ClockOutTime == null); } } bool clockedIn = clockIn != null; var viewModel = new ClockInViewModel { UserId = user.Id, UserName = user.FirstName + " " + user.LastName, TimeSheetId = timeSheet.Id, CurrentlyClockedIn = clockedIn }; ViewBag.Info = "Hello World"; return(View(viewModel)); }
public IActionResult ClockIn() { var user = _userManager.FindByNameAsync(User.Identity.Name).GetAwaiter().GetResult(); var timeSheet = FindUserTimeSheet(user.Id); ClockIn clockIn = null; if (_context.ClockIns.Any(x => x.ClockOutTime == null && x.TimeSheetId == timeSheet.Id)) { clockIn = _context.ClockIns.Last(x => x.ClockOutTime == null && x.TimeSheetId == timeSheet.Id); } bool clockedIn = false; if (clockIn != null) { clockedIn = true; } var viewModel = new ClockInViewModel { UserName = user.FirstName + " " + user.LastName, OnClock = clockedIn, EmployeeId = user.Id }; return(View(viewModel)); }
private void RegisterTime() { CurrentClockIn = _clockInService.Register(DateTime.Now); SetStartEndTime(CurrentClockIn); SetButtonState(CurrentClockIn); }
protected override void OnLoaded() { base.OnLoaded(); ClockIn clockIn = _clockInService.getClockInById(DateTime.Now.Date); SetButtonState(clockIn); }
private void ClockInWaiver(ClockIn clockIn) { TimeSpan hoursToWaive = clockIn.OvertimeHours.Negate(); _settingsService.UpdateProfileAcumulatedHours(hoursToWaive); AccumulatedHours = _settingsService.GetProfileAccumulatedHours(); _historyService.AllowWaiver(clockIn); }
private void SetStartEndTime(ClockIn clockIn) { if (clockIn != null) { StartTime = clockIn.Start.ToString("HH:mm:ss"); if (!clockIn.IsOpen()) { EndTime = clockIn.End.ToString("HH:mm:ss"); } } }
public CurrentDatePageViewModel(IClockInService clockInService, ISettingsService settingsService) { _clockInService = clockInService; _settingsService = settingsService; ClockIn clockIn = _clockInService.getClockInById(DateTime.Now.Date); SetStartEndTime(clockIn); initializeProperties(); InitializeCommands(); InitializeClockInTime(); }
private void SetButtonState(ClockIn clockIn) { if (clockIn != null) { if (clockIn.IsOpen()) { GoToState(REGISTER_OUT_STATE); } else { GoToState(REGISTER_DISABLED); } } }
public ClockIn SaveClockIn(ClockIn clockIn) { if (clockIn.Id == null) { clockIn.Id = DateTime.Now.Date; _repository.ClockInList.Add(clockIn); } else { int index = _repository.ClockInList.FindIndex(0, _repository.ClockInList.Count, ci => ci.Id.Equals(clockIn.Id)); _repository.ClockInList[index] = clockIn; } Persist(); return(clockIn); }
private async void UxClockInButton_Click(object sender, RoutedEventArgs e) { if (SelectedEmployee.current_shift != null) { ContentDialog responseAlert = new ContentDialog { Title = "Already Clocked In", Content = SelectedEmployee.first_name + " " + SelectedEmployee.last_name + " is already clocked in", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } else { var validClockIn = await ClockIn.SendClockInRequest(SelectedEmployee._id); if (validClockIn) { ContentDialog responseAlert = new ContentDialog { Title = "Successful", Content = SelectedEmployee.first_name + " " + SelectedEmployee.last_name + " has been clocked in", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } else { ContentDialog responseAlert = new ContentDialog { Title = "Unsuccessful", Content = SelectedEmployee.first_name + " " + SelectedEmployee.last_name + " has not been clocked in", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } RefreshEmployeeList(); uxTimePopup.IsOpen = false; } }
private bool CheckIsBetweenDates(ClockIn ci, DateTime start, DateTime end) { return(ci.Id >= start && ci.Id <= end); }
public override string ToString() { return($"\n{Oid.ToString()} - {Date.ToString()}\nIN {ClockIn.ToString()}\nOUT {ClockOut.ToString()}\nHrs { getTotalHours().ToString()} Rate ${HourlyRate.ToString()}"); }
public override string ToString() { return($"Oid={Oid.ToString()},Date={Date.ToString()}, ClockIn={ClockIn.ToString()}, ClockOut={ClockOut.ToString()} TotalHours={ TotalHours.ToString()}, HourlyRate={HourlyRate.ToString()} | "); }
public ClockIn AllowWaiver(ClockIn clockIn) { clockIn.AllowWaiver(); return(_persistencyService.SaveClockIn(clockIn)); }