/// <summary>
 /// 
 /// </summary>
 public Diagnozy TransformPoToEntity()
 {
     Diagnozy diag = new Diagnozy();
     diag.nazov = nazov;
     diag.popis = popis;
     return diag;
 }
 private bool FilterDiagnozy(Diagnozy entity)
 {
     return (entity.id_diagnoza == this.id_diagnoza);
 }
 /// <summary>
 /// Create a new Diagnozy object.
 /// </summary>
 /// <param name="id_diagnoza">Initial value of the id_diagnoza property.</param>
 /// <param name="nazov">Initial value of the nazov property.</param>
 /// <param name="tombstone">Initial value of the tombstone property.</param>
 public static Diagnozy CreateDiagnozy(global::System.Int32 id_diagnoza, global::System.String nazov, global::System.Boolean tombstone)
 {
     Diagnozy diagnozy = new Diagnozy();
     diagnozy.id_diagnoza = id_diagnoza;
     diagnozy.nazov = nazov;
     diagnozy.tombstone = tombstone;
     return diagnozy;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Diagnozies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDiagnozies(Diagnozy diagnozy)
 {
     base.AddObject("Diagnozies", diagnozy);
 }
        /// <summary>
        /// button evet click handler, handles Diagnozy synchronization
        /// </summary>
        public void SynchronizeDiagnozy()
        {
            ambulanceDiagonzies = new BindableCollection<Cis_Diagnoza>();
            AmbulanceSynchronizationDomainContext ambulance = _serviceLocator.GetInstance<AmbulanceSynchronizationDomainContext>();
            EntityQuery<Cis_Diagnoza> query = ambulance.GetCis_DiagnozaQuery();
            EntityQuery<Diagnozy> query2 = _laboratoryDomainContext.GetAllDiagnoziesQuery();

            List<IResult> results = new List<IResult>();
            results.Add(Show.Busy());
            LoadData<Cis_Diagnoza> loadResult = new LoadData<Cis_Diagnoza>(ambulance,query,LoadBehavior.RefreshCurrent,(sender) =>
            {
                ambulanceDiagonzies.Clear();
                ambulanceDiagonzies.AddRange(((LoadOperation<Cis_Diagnoza>)sender).Entities);
            }
            );

            LoadData<Diagnozy> loadResult2 = new LoadData<Diagnozy>(_laboratoryDomainContext, query2, LoadBehavior.RefreshCurrent, (sender) =>
            {
                laboratoryDiagnozy.Clear();
                laboratoryDiagnozy.AddRange(((LoadOperation<Diagnozy>)sender).Entities);
                bool found = false;

                foreach (var item in ambulanceDiagonzies)
                {
                    for (int i = 0; i < laboratoryDiagnozy.Count; i++)
                    {
                        found = false;
                        if (item.Nazov == laboratoryDiagnozy[i].nazov && item.Poznamka == laboratoryDiagnozy[i].popis)
                        {
                            laboratoryDiagnozy.RemoveAt(i);
                            found = true;
                            break;
                        }
                    }

                    if (found == false)
                    {
                        Diagnozy novaDiagnoza = new Diagnozy();
                        novaDiagnoza.nazov = item.Nazov;
                        novaDiagnoza.popis = item.Poznamka;
                        _laboratoryDomainContext.Diagnozies.Add(novaDiagnoza);
                    }
                }
                _laboratoryDomainContext.SubmitChanges();
                Coroutine.BeginExecuteFor(Show.NotBusy(), this);

            }
            );
            results.Add(loadResult);
            results.Add(loadResult2);

            Coroutine.BeginExecuteFor(results, this);
        }
        private void GetHodnotyLatky(BindableCollection<Vysetrenie_Vysetrovane_latky> vysledkyVys, Vzorky vzorka, Diagnozy diag)
        {
            _laboratoryDomainContext.Vysetrovane_latkies.Clear();
            _laboratoryDomainContext.Load(_laboratoryDomainContext.GetVzorkaVysetrovaneLatkyQuery(Vysetrenie.id_vzorka)).Completed += (sender4, e4) =>
            {
                _laboratoryDomainContext.Hodnoty_Vysetrovane_Latkies.Clear();
                _laboratoryDomainContext.Load(_laboratoryDomainContext.GetVysetrenieHodnotyVysetrovaneLatkyQuery(Vysetrenie.id_vysetrenie)).Completed += (sender5, e5) =>
                {
                    BindableCollection<Hodnoty_Vysetrovane_Latky> hodnoty = new BindableCollection<Hodnoty_Vysetrovane_Latky>();
                    foreach (var item in _laboratoryDomainContext.Hodnoty_Vysetrovane_Latkies)
                    {
                        hodnoty.Add(item);
                    }
                    BindableCollection<Vysetrovane_latky> latky = new BindableCollection<Vysetrovane_latky>();
                    foreach (var item in _laboratoryDomainContext.Vysetrovane_latkies)
                    {
                        latky.Add(item);
                    }
                    Vysledky = new BindableCollection<AddVysledokPo>();
                    AddVysledokPo novyVysledok;
                    foreach (var item in vysledkyVys)
                    {

                        novyVysledok = new AddVysledokPo();
                        Vysledky.Add(novyVysledok);
                        novyVysledok.TransormEntityToPo(item, Pacient, vzorka, diag, hodnoty, latky);
                        RaisePropertyChangedEventImmediately("Vysledky");
                    }

                    Coroutine.BeginExecuteFor(Show.NotBusy(), this);
                };
            };
        }
 public void UpdateDiagnozy(Diagnozy currentDiagnozy)
 {
     this.ObjectContext.Diagnozies.AttachAsModified(currentDiagnozy, this.ChangeSet.GetOriginal(currentDiagnozy));
 }
 public void InsertDiagnozy(Diagnozy diagnozy)
 {
     if ((diagnozy.EntityState != EntityState.Detached))
     {
         this.ObjectContext.ObjectStateManager.ChangeObjectState(diagnozy, EntityState.Added);
     }
     else
     {
         this.ObjectContext.Diagnozies.AddObject(diagnozy);
     }
 }
        public Diagnozy GetDiagnozaForVysetrenieImport(string nazov)
        {
            if (nazov == null || nazov == "")
            {
                return null;
            }
            else
            {
                Diagnozy res = null;
                try
                {
                    res = (from a in ObjectContext.Diagnozies
                           where a.nazov == nazov
                           select a).First();
                }
                catch (InvalidOperationException)
                {
                }

                if (res != null)
                {
                    return res;
                }
                else
                {
                    Diagnozy diag = new Diagnozy();
                    diag.nazov = nazov;
                    InsertDiagnozy(diag);
                    ObjectContext.SaveChanges();
                    return diag;
                }
            }
        }