public int PostEmployeeTimeRecord(EmployeeTimeRecord employeeTimeRecord) { var count = _timeTrackerDbContext.EmployeeTimeRecord.Count(); employeeTimeRecord.ID = ++count; _timeTrackerDbContext.EmployeeTimeRecord.Add(employeeTimeRecord); _timeTrackerDbContext.SaveChanges(); return(1); }
private TimeRecord ExtractTimeRecord(EmployeeTimeRecord employeeTimeRecord) { TimeRecord tr = new TimeRecord(); tr.Comments = employeeTimeRecord.Comments; tr.StartTimeRec = GetTimeString(employeeTimeRecord.StartTimeMinutes); tr.EndTimeRec = GetTimeString(employeeTimeRecord.EndTimeMinutes); tr.Task = employeeTimeRecord.Task; return(tr); }
private void OnSubmitTaskTimeCommandHandler() { EmployeeTimeRecord employeeTimeRecord = new EmployeeTimeRecord(); employeeTimeRecord.Date = SelectedDate; employeeTimeRecord.Comments = Comments; employeeTimeRecord.EmployeeID = _employee.ID; employeeTimeRecord.Task = TaskName; var projectTasks = _timeTrackerRepository.GetProjectTasks(_employee.Project.ID); bool containsSelectedTask = false; foreach (var item in projectTasks) { if (item.Name.Equals(TaskName)) { containsSelectedTask = true; break; } } if (!containsSelectedTask) { ProjectTask projectTask = new ProjectTask(); projectTask.Name = TaskName; projectTask.Project = _timeTrackerRepository.GetProject(_employee.Project.ID); _timeTrackerRepository.PostProjectTasks(projectTask); } int startTimeValueMinutes = 0; if (int.TryParse(StartTimeValue, out startTimeValueMinutes)) { employeeTimeRecord.StartTimeMinutes = startTimeValueMinutes; } int endTimeValueMinutes = 0; if (int.TryParse(EndTimeValue, out endTimeValueMinutes)) { employeeTimeRecord.EndTimeMinutes = endTimeValueMinutes; } _timeTrackerRepository.PostEmployeeTimeRecord(employeeTimeRecord); RecordedList.Clear(); TaskList.Clear(); RecordedList = ConvertRecords(_timeTrackerRepository.GetEmployeeTimeRecords(_employee.ID, SelectedDate)); TaskList = new ObservableCollection <string>(_timeTrackerRepository.GetProjectTasks(_employee.Project.ID).Select(pt => pt.Name)); }