private async void Enable(object sender, EventArgs e) { var img = ((Image)sender); var releasedHour = img.BindingContext as Model.ReleasedHourModel; var reply = await _messageService.DisplayConfirm($"Tem certeza que deseja ativar o lançamento {releasedHour.DataHoraLancada}?"); if (reply) { var idApp = App.Current.Properties["IdApp"] as string; var resultApi = await _apiService.HabilitaHora(idApp, releasedHour.IdLancamento); if (resultApi.ValidadoOk) { var releasedHourDb = _releasedHoursRepository.Find(b => b.Il == releasedHour.IdLancamento).First(); releasedHourDb.St = "0"; _releasedHoursRepository.Update(releasedHourDb); btnEnable.IsVisible = true; img.IsVisible = false; } } }
private void SaveData(AppData data) { var idApp = App.Current.Properties["IdApp"] as string; foreach (var user in data.Uss) { var userDb = _appUserRepository.Find(a => a.Iu == user.Iu); var userDbFirst = userDb.FirstOrDefault(); if (!ReferenceEquals(userDbFirst, null)) { userDbFirst.Au = user.Au; userDbFirst.Ii = user.Ii; userDbFirst.St = user.St; userDbFirst.Xl = user.Xl; userDbFirst.Ca = user.Ca; _appUserRepository.Update(userDbFirst); } else { _appUserRepository.Save(user); } } foreach (var passclock in data.Pcs) { var passclockDb = _passclockRepository.Find(a => a.Pc == passclock.Pc); var passclockFirst = passclockDb.FirstOrDefault(); if (!ReferenceEquals(passclockFirst, null)) { passclockFirst.Ap = passclock.Ap; passclockFirst.Cv = passclock.Cv; passclockFirst.St = passclock.St; _passclockRepository.Update(passclockFirst); } else { _passclockRepository.Save(passclock); } } if (data.Lns.Any()) { var lastReleasedDb = _releasesHistoryRepository.Find(a => a.Iu == idApp).FirstOrDefault(); var lastReleased = data.Lns.OrderByDescending(b => System.Convert.ToInt32(b.Il)).First(); if (ReferenceEquals(lastReleasedDb, null)) { _releasesHistoryRepository.Save(new ReleasesHistory { Il = lastReleased.Il, Iu = idApp }); } else { lastReleasedDb.Il = lastReleased.Il; _releasesHistoryRepository.Update(lastReleasedDb); } } this.CountListReleaseHours = _releasedHourRepository.CountToday(); _releasedHourRepository.ExcludeLastTwoMonths(); foreach (var releasedHour in data.Lns) { var releasedHourDb = _releasedHourRepository.Find(a => a.Il == releasedHour.Il); var releasedHourFirst = releasedHourDb.FirstOrDefault(); if (!ReferenceEquals(releasedHourFirst, null)) { releasedHourFirst.Ap = releasedHour.Ap; releasedHourFirst.Au = releasedHour.Au; releasedHourFirst.Cd = releasedHour.Cd; releasedHourFirst.Di = releasedHour.Di; releasedHourFirst.Hd = releasedHour.Hd; releasedHourFirst.He = releasedHour.He; releasedHourFirst.Hl = releasedHour.Hl; releasedHourFirst.Hdx = releasedHour.Hdx; releasedHourFirst.Hex = releasedHour.Hex; releasedHourFirst.Hlx = releasedHour.Hlx; releasedHourFirst.La = releasedHour.La; releasedHourFirst.Lo = releasedHour.Lo; releasedHourFirst.Nt = releasedHour.Nt; releasedHourFirst.Pc = releasedHour.Pc; releasedHourFirst.St = releasedHour.St; releasedHourFirst.Tz = releasedHour.Tz; releasedHourFirst.Il = releasedHour.Il; _releasedHourRepository.Update(releasedHourFirst); } else { _releasedHourRepository.Save(releasedHour); } } }