//выгрузка изображения public BitmapImage LoadImage() { Place_information place1 = new Place_information(); using (var context = new MyDbContext()) { var places = context.Place_information; foreach (var a in places) { place1 = context.Place_information.FirstOrDefault(x => x.Id_place == Place.ID); } } var image = new BitmapImage(); using (var mem = new MemoryStream(place1.Photo_place)) { mem.Position = 0; image.BeginInit(); image.CreateOptions = BitmapCreateOptions.PreservePixelFormat; image.CacheOption = BitmapCacheOption.OnLoad; image.UriSource = null; image.StreamSource = mem; image.EndInit(); } image.Freeze(); return(image); }
public void AddNewTour(string name, string description) { try { int ID_PL = 0; if (name.Length > 0 && description.Length > 0 && imageData != null) { ValidationViewModel.NoPoint(name); ValidationViewModel.Description(description); using (var context = new MyDbContext()) { var place = context.Places; var place_inf = context.Place_information; Place place1 = new Place { Place_name = name, Place_adress = " ", Place_type = "экскурсии" }; foreach (var a in place) { if (a.Place_adress == place1.Place_adress && a.Place_name == place1.Place_name && a.Place_type == place1.Place_type) { MessageBox.Show("Такая экскурсия уже существует"); return; } } place.Add(place1); context.SaveChanges(); foreach (var a in place) { if (a.Place_name == name) { ID_PL = a.Id; } } Place_information place_Information1 = new Place_information { Id_place = ID_PL, Place_discriptin = description, Photo_place = imageData }; place_inf.Add(place_Information1); context.SaveChanges(); window.OpenPage(MainWindow.Pages.AdminPage); } } else { MessageBox.Show("Не все данные введены"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public string Text() { Place_information text1 = new Place_information(); using (var context = new MyDbContext()) { var places = context.Place_information; foreach (var a in places) { text1 = context.Place_information.FirstOrDefault(x => x.Id_place == Place.ID); } } return(text1.Place_discriptin); }