/// <summary> /// Deletes a labor entry /// </summary> public Task DeleteLaborAsync (Assignment assignment, Labor labor) { return service.DeleteLaborAsync (labor) .ContinueWith (t => { laborHours.Remove (labor); CalculateHours (assignment); }); }
public Task <int> SaveLaborAsync(Labor labor, CancellationToken cancellationToken = default(CancellationToken)) { if (labor.Id == 0) { return(Database.GetConnection(cancellationToken).InsertAsync(labor)); } else { return(Database.GetConnection(cancellationToken).UpdateAsync(labor)); } }
/// <summary> /// Saves a labor entry /// </summary> public Task SaveLaborAsync (Assignment assignment, Labor labor) { bool newItem = labor.Id == 0; return service.SaveLaborAsync (labor) .ContinueWith (t => { if (newItem) laborHours.Add (labor); CalculateHours (assignment); }); }
/// <summary> /// Sets the labor hours on this cell /// </summary> public void SetLabor(Labor labor) { type.Text = labor.TypeAsString; description.Text = labor.Description; hours.Text = labor.Hours.ToString (@"hh\:mm\:ss"); type.TextColor = description.TextColor = hours.TextColor = Theme.LabelColor; type.HighlightedTextColor = description.HighlightedTextColor = hours.HighlightedTextColor = Theme.LabelColor; }
public LaborViewModel () { assignmentViewModel = ServiceContainer.Resolve<AssignmentViewModel> (); cancelAddLaborCommand = new DelegateCommand (_ => { addLaborPopUp.IsOpen = false; }); saveAddLaborCommand = new DelegateCommand (async _ => { selectedLabor.Hours = TimeSpan.FromHours (currentLaborHours.ToDouble (CultureInfo.InvariantCulture)); selectedLabor.AssignmentId = assignmentViewModel.SelectedAssignment.Id; await SaveLaborAsync (assignmentViewModel.SelectedAssignment, selectedLabor); await LoadLaborHoursAsync (assignmentViewModel.SelectedAssignment); addLaborPopUp.IsOpen = false; }); deleteAddLaborCommand = new DelegateCommand (async _ => { await DeleteLaborAsync (assignmentViewModel.SelectedAssignment, selectedLabor); await LoadLaborHoursAsync (assignmentViewModel.SelectedAssignment); addLaborPopUp.IsOpen = false; }); addLaborCommand = new DelegateCommand (obj => { var labor = obj as Labor; if (labor != null) { SelectedLabor = labor; AddLaborHeader = "Labor"; CanDelete = true; } else { SelectedLabor = new Labor (); AddLaborHeader = "Add Labor"; CanDelete = false; } if (addLaborPopUp != null && addLaborPopUp.IsOpen) { addLaborPopUp.IsOpen = false; } addLaborPopUp = new Popup (); addLaborPopUp.Height = Window.Current.Bounds.Height; addLaborPopUp.Width = Constants.PopUpWidth; AddLaborFlyoutPanel flyoutpanel = new AddLaborFlyoutPanel (); flyoutpanel.Width = addLaborPopUp.Width; flyoutpanel.Height = addLaborPopUp.Height; addLaborPopUp.Child = flyoutpanel; addLaborPopUp.SetValue (Canvas.LeftProperty, Window.Current.Bounds.Width - Constants.PopUpWidth); addLaborPopUp.SetValue (Canvas.TopProperty, 0); addLaborPopUp.IsOpen = true; }); }
/// <summary> /// Pauses timer /// </summary> public Task PauseAsync () { if (activeAssignment == null || timerEntry == null) return Task.Factory.StartNew (delegate { }); IsBusy = true; Recording = false; var labor = new Labor { Type = LaborType.Hourly, AssignmentId = activeAssignment.Id, Description = "Time entered automatically at: " + DateTime.Now.ToShortTimeString (), Hours = (DateTime.Now - timerEntry.Date), }; return service .SaveLaborAsync (labor) .ContinueWith (service.DeleteTimerEntryAsync (timerEntry)) .ContinueOnCurrentThread (_ => { CurrentHours = TimeSpan.Zero; IsBusy = false; }); }
public Task <int> DeleteLaborAsync(Labor labor, CancellationToken cancellationToken) { return(Database.GetConnection(cancellationToken).DeleteAsync(labor)); }
public Task<int> DeleteLaborAsync (Labor labor, CancellationToken cancellationToken) { return Task.Factory.StartNew (() => 1); }
public void DeleteLabor () { var labor = new Labor (); labor.Description = "New Description"; var saveTask = service.SaveLaborAsync (labor, CancellationToken.None); saveTask.Wait (); var deleteTask = service.DeleteLaborAsync (labor, CancellationToken.None); deleteTask.Wait (); Assert.That (deleteTask.Result, Is.EqualTo (1)); }
public Task<int> DeleteLaborAsync (Labor labor, CancellationToken cancellationToken) { return Database.GetConnection (cancellationToken).DeleteAsync (labor); }
public Task<int> SaveLaborAsync (Labor labor, CancellationToken cancellationToken = default(CancellationToken)) { if (labor.Id == 0) return Database.GetConnection (cancellationToken).InsertAsync (labor); else return Database.GetConnection (cancellationToken).UpdateAsync (labor); }