private void dodajPrzepisAkcja() { EntityMethods en = new EntityMethods(); ElementGrid pTest = null; if (ParentVM.listaPrzepisow.Count > 0) { try { pTest = ParentVM.listaPrzepisow.First(x => x.NAZWA == nazwa); } catch (Exception) { pTest = null; } } if (pTest == null) { Przepisy p = new Przepisy(); p.NAZWA = nazwa; p.NOTATKI = notatki; p.OPIS = opis; p.ILOSC_PORCJI = Double.Parse(iloscPorcji); p.ID_KATEGORII = en.idKategoriiPrzepisu(kategorieSelection); int czas = 0; if (czasH != null) { czas = Int32.Parse(czasH) * 60 + Int32.Parse(czasM); } else { czas = Int32.Parse(czasM); } p.CZAS_PRZYRZADZENIA = czas; if (isEdit == false) { string path = ((BitmapImage)zdjecie).UriSource.OriginalString; byte[] image = File.ReadAllBytes(path); p.ZDJECIE = image; idEdytowanegoPrzepisu = en.dodajPrzepis(p); } else { if (zdjecie.GetType() == typeof(BitmapImage)) { string path = ((BitmapImage)zdjecie).UriSource.OriginalString; byte[] image = File.ReadAllBytes(path); p.ZDJECIE = image; } else { p.ZDJECIE = null; } p.ID_PRZEPISU = (int)idEdytowanegoPrzepisu; en.edytujPrzepis(p); en.czyscPrzepisySkladniki((int)idEdytowanegoPrzepisu); } List <Przepisy_Skladniki> lista = new List <Przepisy_Skladniki>(); foreach (SkladnikPrzepisu sp in listaSkladnikow) { Przepisy_Skladniki ps = new Przepisy_Skladniki(); ps.L_ID_PRZEPISU = (int)idEdytowanegoPrzepisu; if (sp.ILOSC != null) { ps.ILOSC = sp.ILOSC; } if (!String.IsNullOrWhiteSpace(sp.JEDNOSTKA)) { ps.ID_JEDNOSTKI = en.pobierzIdJednostki(sp.JEDNOSTKA); } ps.L_ID_SKLADNIKA = en.idSkladnika(sp.NAZWA); en.dodajPrzepisySkladniki(ps); } ParentVM.wypiszPrzepisy((int)idEdytowanegoPrzepisu); CloseAction(); } else { MessageBoxShow mb = new MessageBoxShow(); mb.pokazMessageBox("Informacja", "Został już dodany taki przepis.", MessageBoxTyp.Normalny, MessageBoxIkona.Informacyjna); } }