private async void SaveCommandExecute() { if (!IsProcessing) { IsProcessing = true; ReportItem.Day = DateControl.Day; ReportItem.Month = DateControl.Month; ReportItem.Year = DateControl.Year; if (Editing) { ReportItemDatabase.Update(ReportItem); } else { if (!ReportItem.IsEmpty()) { ReportItemDatabase.Save(ReportItem); } } } await NavigationService.GoBackAsync(); IsProcessing = false; }
private async void TransferCommandExecute() { TimeSpan totalReport = ReportUtils.ToTimeSpan(ReportSummary).Duration(); var a = DateTime.Now; var answer = await DialogService.DisplayAlertAsync("Transferir Minutos", $"Deseja mesmo transferir {totalReport.Minutes} minutos para o mês atual?", "Sim", "Não"); if (answer) { var now = DateTime.Now; ReportItemDatabase.Save(new ReportItem(DateControl.Month, ReportUtils.DaysInMonth(DateControl), DateControl.Year, totalReport.Minutes * -1)); ReportItemDatabase.Save(new ReportItem(now.Month, now.Day, now.Year, totalReport.Minutes)); DateControl = now; HandleDateControlChange(); } }
private void StartCounterCommandExecute() { CounterStarted = !CounterStarted; HandleCounterIcon(); if (CounterStarted) { if (CounterTimestamp == null) { CounterTimestamp = new CounterTimestamp { InitialTimestamp = DateTime.Now.Ticks, Started = true }; ReportItemDatabase.Save(CounterTimestamp); } else { CounterTimestamp.InitialTimestamp = DateTime.Now.Ticks; CounterTimestamp.Started = true; ReportItemDatabase.GetDatabase().Update(CounterTimestamp); } CounterText = ReportUtils.FormatHourToCounter(new TimeSpan(CounterTimestamp.InitialTimestamp)); } else { if (CounterTimestamp != null) { var now = DateTime.Now; long inicialDate = CounterTimestamp.InitialTimestamp; long finalDate = now.Ticks; TimeSpan totalTime = new TimeSpan(finalDate - inicialDate).Duration(); CounterTimestamp.Started = false; ReportItemDatabase.Update(CounterTimestamp); var reportItem = new ReportItem(now.Month, now.Day, now.Year, totalTime.Hours, totalTime.Minutes); var navigationParams = new NavigationParameters(); navigationParams.Add(EzraConstants.REPORT_ITEM_NAV_PARAM, (ReportItem)reportItem); navigationParams.Add(EzraConstants.IS_EDITING_NAV_PARAM, false); NavigationService.NavigateAsync(EzraConstants.REPORT_EDITION_PAGE, navigationParams); } } }