private void BtnOkClick(object sender, RoutedEventArgs e) { if (loginName == "admin") { iscorrect = (markercontext.Name != null && markercontext.Street != null && markercontext.City != null && markercontext.StreetNumber != null && markercontext.MyImageSource != null && markercontext.Description != null && MarkerType_combo.Text != null); } else { iscorrect = (markercontext.Name != null && markercontext.Street != null && markercontext.City != null && markercontext.StreetNumber != null && markercontext.MyImageSource != null && markercontext.Description != null); } if (iscorrect) { DialogResult = true; byte[] picture = File.ReadAllBytes(markercontext.MyImageSource); PointLatLng pointLatLng = GetCoordinates(markercontext.City, markercontext.Street, markercontext.StreetNumber); if (pointLatLng.IsEmpty || pointLatLng.Lat == 0 || pointLatLng.Lng == 0) { MessageBox.Show("Incorect Address!"); return; } string markerType = "user"; if (loginName == "admin") { markerType = MarkerType_combo.Text; } Marker marker = new Marker() { Name = markercontext.Name, City = markercontext.City, Contacts = markercontext.Contacts.ToArray(), Description = markercontext.Description, Lat = pointLatLng.Lat, Lng = pointLatLng.Lng, MarkerType = markerType, Number = markercontext.StreetNumber, Picture = picture, Street = markercontext.Street, UserName = loginName }; if (loginName != String.Empty) { bll.AddNewPlace(marker); MessageBox.Show("New marker was added!"); } else { MessageBox.Show("New marker was created!"); } Close(); } else { DialogResult = false; MessageBox.Show("Incorrect value!"); Close(); } }
private void AddUserPlace(MarkerContext context) { PointLatLng pointLatLng = GetCoordinates(context.City, context.Street, context.StreetNumber); Image image = new Image(); image.Source = new BitmapImage(new Uri(context.MyImageSource)); var byteimage = ImageToByte(image.Source as BitmapImage); Marker newmarker = new Marker() { Name = context.Name, City = context.City, Street = context.Street, Number = context.StreetNumber, Contacts = context.Contacts.ToArray(), Description = context.Description, Lat = pointLatLng.Lat, Lng = pointLatLng.Lng, MarkerType = context.Type, Picture = byteimage, UserName = LoginName }; bll.AddNewPlace(newmarker); }