コード例 #1
0
        private void BindData()
        {
            using (var db = new JakNaPiwoContext())
            {
                currentPub = db.Pubs.FirstOrDefault(p => p.Id == selectedBeer.PubID);
            }

            beerNameTextView.Text         = selectedBeer.Name;
            beerTypeTextView.Text         = "Typ: " + selectedBeer.Type;
            shortDescriptionTextView.Text = selectedBeer.ShortDescription;
            priceTextView.Text            = "Cena: " + selectedBeer.Price + "zł";
            if (currentPub == null)
            {
                pubAdresTextView.Text = " ";
            }
            else
            {
                pubAdresTextView.Text = "Miejsce: " + currentPub.Name + " " + currentPub.Address;
            }

            beerRatingRatingBar.Rating = selectedBeer.BeerRating;

            //int height = beerImageView.Height;
            //int width = beerImageView.Width;
            int    height      = 200;
            int    width       = 200;
            Bitmap imageBitmap = ImageHelper.GetImageBitmapFromFilePath(selectedBeer.ImagePath, width, height);

            beerImageView.SetImageBitmap(imageBitmap);
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here


            var selectedPubId = Intent.Extras.GetInt("selectedPubId");

            //tu pobranie piwa z bazy danyh
            using (var db = new JakNaPiwoContext())
            {
                selectedPub = db.Pubs.FirstOrDefault(p => p.Id == selectedPubId);

                pubLocation = new LatLng(selectedPub.PubLatitude, selectedPub.PubLongitude);
                pubName     = selectedPub.Name;
            }



            SetContentView(Resource.Layout.PubMapView);

            FindViews();

            HandleEvents();

            CreateMapFragment();

            UpdateMapView();
        }
コード例 #3
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            using (var db = new JakNaPiwoContext())
            {
                newPubId = db.Pubs.LastOrDefault().Id;
            }


            var newBeer = new Beer
            {
                Name             = nameEditText.Text,
                Type             = selectedSpinner,
                TypeID           = selectedSpinnerID,
                BeerRating       = beerRatingRatingBar.Rating,
                ShortDescription = shortDescriptionEditText.Text,
                Price            = float.Parse(priceEditText.Text),
                ImagePath        = (string)imageFile,
                PubID            = newPubId
            };

            Toast.MakeText(this.Activity, "Piwo " + newBeer.Name + " zostało dodane!", ToastLength.Short).Show();

            using (var db = new JakNaPiwoContext())
            {
                db.connection.Insert(newBeer, typeof(Beer));

                var intent = new Intent();
                intent.SetClass(this.Activity, typeof(BeerDetailActivity));
                // pobiera Id ostatnio dodanego elementu
                intent.PutExtra("selectedBeerId", db.Beers.LastOrDefault().Id);
                StartActivityForResult(intent, 100);
            }
        }
コード例 #4
0
        public List <Beer> GetAllBeers()
        {
            using (var db = new JakNaPiwoContext())
            {
                IEnumerable <Beer> beers = db.Beers.ToList();

                return(beers.ToList());
            }
        }
コード例 #5
0
        public List <Pub> GetAllPubs()
        {
            using (var db = new JakNaPiwoContext())
            {
                IEnumerable <Pub> pubs = db.Pubs.ToList();

                return(pubs.ToList());
            }
        }
コード例 #6
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            using (var db = new JakNaPiwoContext())
            {
                var beer = db.Beers.FirstOrDefault(b => b.Id == editBeer.Id);

                db.DeleteBeerTable(beer);
            }

            Toast.MakeText(this, "Piwo " + editBeer.Name + " zostało usunięte!", ToastLength.Short).Show();
            Intent nextActivity = new Intent(this, typeof(BeerMenuActivity));

            StartActivity(nextActivity);
        }
コード例 #7
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var newPub = new Pub
            {
                Name    = nameEditText.Text,
                Address = cityEditText.Text + " " + streetEditText.Text + " " + numberEditText.Text,
                City    = cityEditText.Text,
                Street  = streetEditText.Text,
                Number  = numberEditText.Text
            };

            addressToGeoLocator = newPub.Address;

            using (var db = new JakNaPiwoContext())
            {
                var location = getLocation();

                var intent = new Intent();

                if (location == null)
                {
                    intent.SetClass(this, typeof(AddPubActivity));
                }
                else
                {
                    newPub.PubLatitude  = location[0];
                    newPub.PubLongitude = location[1];
                }

                db.connection.Insert(newPub, typeof(Pub));

                if (view == "editBeer")
                {
                    intent.SetClass(this, typeof(EditBeerActivity));
                    intent.PutExtra("editBeerId", editBeerId);
                }
                else
                {
                    intent.SetClass(this, typeof(BeerMenuActivity));
                    intent.SetFlags(ActivityFlags.ReorderToFront);
                }

                intent.PutExtra("newPubId", db.Pubs.LastOrDefault().ToString());
                StartActivityForResult(intent, 100);
            }
        }
コード例 #8
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            // tu muszę zrobić by zapisało newImageFile jako nową ścieżkę do zdjęcia, a te poprzednie zdjęcie usuneło
            //File.Delete(editBeer.ImagePath) chyba coś takiego
            //var Image = (string)imageFile;

            using (var db = new JakNaPiwoContext())
            {
                var beer = db.Beers.FirstOrDefault(b => b.Id == editBeer.Id);

                beer.Name             = nameEditText.Text;
                beer.Type             = selectedSpinner;
                beer.TypeID           = selectedSpinnerID;
                beer.BeerRating       = beerRatingRatingBar.Rating;
                beer.ShortDescription = shortDescriptionEditText.Text;
                beer.Price            = float.Parse(priceEditText.Text);

                if (receiveImagePath == null)
                {
                    if (image == null)
                    {
                        beer.ImagePath = " ";
                    }
                    else
                    {
                        beer.ImagePath = image;
                    }
                }
                else
                {
                    beer.ImagePath = receiveImagePath;
                }

                db.UpdateBeerTable(beer);
            }

            Toast.MakeText(this, "Piwo " + editBeer.Name + " zostało zaktualizowane!", ToastLength.Short).Show();

            var intent = new Intent();

            intent.SetClass(this, typeof(BeerDetailActivity));
            intent.PutExtra("selectedBeerId", editBeer.Id);

            StartActivityForResult(intent, 100);
        }
コード例 #9
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            editPub.Name    = nameEditText.Text;
            editPub.Address = cityEditText.Text + " " + streetEditText.Text + " " + numberEditText.Text;
            editPub.City    = cityEditText.Text;
            editPub.Street  = streetEditText.Text;
            editPub.Number  = numberEditText.Text;

            addressToGeoLocator = editPub.Address;

            using (var db = new JakNaPiwoContext())
            {
                var location = getLocation();

                var intent = new Intent();

                if (location == null)
                {
                    intent.SetClass(this, typeof(AddPubActivity));
                }
                else
                {
                    editPub.PubLatitude  = location[0];
                    editPub.PubLongitude = location[1];
                }

                db.UpdatePubTable(editPub);

                if (view == "editBeer")
                {
                    intent.SetClass(this, typeof(EditBeerActivity));
                    intent.PutExtra("editBeerId", editBeerId);
                }
                else
                {
                    intent.SetClass(this, typeof(BeerMenuActivity));
                    intent.SetFlags(ActivityFlags.ReorderToFront);
                }

                intent.PutExtra("newPubId", editPub.Id.ToString());
                StartActivityForResult(intent, 100);
            }
        }
コード例 #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.BeerMenuView);

            //beerService = new BeerService();
            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

            AddTab("Piwa", Resource.Drawable.icon, new BeerFragment());
            AddTab("Puby", Resource.Drawable.icon, new PubFragment());
            AddTab("Dodaj", Resource.Drawable.icon, new AddBeerFragment());
            AddTab("Szukaj", Resource.Drawable.icon, new SearchBeerFragment());


            using (var db = new JakNaPiwoContext())
            {
            }

            //var saveImageFile = Intent.Extras.GetStringExtra("imageFileBeer");
        }
コード例 #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.BeerDetailView);

            beerService = new BeerService();

            var selectedBeerId = Intent.Extras.GetInt("selectedBeerId");

            using (var db = new JakNaPiwoContext())
            {
                selectedBeer = db.Beers.FirstOrDefault(b => b.Id == selectedBeerId);

                currentPub = db.Pubs.FirstOrDefault(p => p.Id == selectedBeer.PubID);
            }

            FindViews();
            BindData();
            HandleEvents();
        }
コード例 #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.EditPubView);

            // Create your application here

            var editPubId = Intent.Extras.GetInt("editPubId");

            view       = Intent.GetStringExtra("view");
            editBeerId = Intent.Extras.GetInt("editBeerId");

            using (var db = new JakNaPiwoContext())
            {
                editPub = db.Pubs.FirstOrDefault(b => b.Id == editPubId);
            }

            FindViews();
            BindData();
            HandleEvents();
        }
コード例 #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            //tu pobranie pubów z bazy danyh
            using (var db = new JakNaPiwoContext())
            {
                pubs = db.Pubs.ToList();
            }

            //pubs = beerService.GetAllPubs();

            SetContentView(Resource.Layout.PubMapView);

            FindViews();

            CreateMapFragment();

            UpdateMapView();
        }
コード例 #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.EditBeerView);
            // Create your application here

            var editBeerId = Intent.Extras.GetInt("editBeerId");

            int newPubId = -1;

            if (Intent.GetStringExtra("newPubId") != null)
            {
                newPubId = int.Parse(Intent.GetStringExtra("newPubId"));
            }

            receiveImagePath = Intent.GetStringExtra("imagePath");

            using (var db = new JakNaPiwoContext())
            {
                editBeer = db.Beers.FirstOrDefault(b => b.Id == editBeerId);

                currentPub = db.Pubs.FirstOrDefault(p => p.Id == editBeer.PubID);

                if (newPubId != -1)
                {
                    newPub = db.Pubs.FirstOrDefault(p => p.Id == newPubId);
                }
            }

            image = editBeer.ImagePath;

            FindViews();
            SpinnerStaff();
            BindData();

            HandleEvents();
        }