protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); App.Current.ContextoAtual = ctx; if (App.Current.AtendimentoAtual < 0) { Web.Atendimento atendimento = new Web.Atendimento { PacienteId = App.Current.PacienteAtual, MedicoId = 1, Horario = DateTime.Now }; ctx.Atendimentos.Add(atendimento); var submitOperation = ctx.SubmitChanges(); submitOperation.Completed += (s, ex) => { if (submitOperation.HasError) { MessageBox.Show(submitOperation.Error.Message); return; } if (submitOperation.ChangeSet.Count() == 0) { MessageBox.Show("Erro ao carregar atendimento"); return; } App.Current.AtendimentoAtual = ((Web.Atendimento)submitOperation.ChangeSet.AddedEntities.First()).Id; ObtemAtendimentoAtual(); }; } else ObtemAtendimentoAtual(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); App.Current.ContextoAtual = ctx; if (App.Current.AtendimentoAtual < 0) { Web.Atendimento atendimento = new Web.Atendimento { PacienteId = App.Current.PacienteAtual, MedicoId = 1, Horario = DateTime.Now }; ctx.Atendimentos.Add(atendimento); var submitOperation = ctx.SubmitChanges(); submitOperation.Completed += (s, ex) => { if (submitOperation.HasError) { MessageBox.Show(submitOperation.Error.Message); return; } if (submitOperation.ChangeSet.Count() == 0) { MessageBox.Show("Erro ao carregar atendimento"); return; } App.Current.AtendimentoAtual = ((Web.Atendimento)submitOperation.ChangeSet.AddedEntities.First()).Id; ObtemAtendimentoAtual(); }; } else { ObtemAtendimentoAtual(); } }