示例#1
0
        public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        {
            if (segue.Identifier != "beerDescriptionSegue")
            {
                return;
            }

            /*
             * var index = placeHolderTableView.IndexPathForSelectedRow.Row;
             * selectedBeer = selectedBeer ?? viewModel.Beers[index];
             */
            selectedBeer.Upc        = barcodeLookupService.UPC;
            selectedBeer.RateBeerId = barcodeLookupService.RateBeerID;

            var beerDescriptoinViewController = segue.DestinationViewController as BeerDescriptionTableView;

            if (beerDescriptoinViewController == null)
            {
                return;
            }

            beerDescriptoinViewController.EnableCheckIn = true;
            beerDescriptoinViewController.SetBeer(selectedBeer);

            selectedBeer = null;
        }
示例#2
0
        public static BeerItem ToBeerItem(this Beer beer, BeerItem beerItem = null)
        {
            if (beerItem == null)
            {
                beerItem = new BeerItem
                {
                    Id          = beer.Id,
                    BreweryDBId = beer.Id,
                };
            }

            beerItem.Name        = beer.Name;
            beerItem.Description = beer.Description;
            if (beer.Breweries != null && beer.Breweries.Any())
            {
                beerItem.Brewery = beer.Brewery;
            }

            beerItem.ABV = beer.Abv;
            if (beer.Labels != null)
            {
                beerItem.Icon   = beer.Labels.Icon;
                beerItem.Medium = beer.Labels.Medium;
                beerItem.Large  = beer.Labels.Large;
            }
            return(beerItem);
        }
示例#3
0
        public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
        {
            switch (userActivity.ActivityType)
            {
            case "com.micjames.beerdrinkin.mybeers":
                break;

            case "com.micjames.beerdrinkin.wishlist":
                break;

            case "com.micjames.beerdrinkin.search":
                break;

            case "com.micjames.beerdrinkin.profile":
                break;

            case "com.micjames.beerdrinkin.beerdetails":
                var info = userActivity.UserInfo;
                if (this.Window.RootViewController.ChildViewControllers[0] is UITabBarController)
                {
                    var tabController = this.Window.RootViewController.ChildViewControllers[0] as UITabBarController;
                    tabController.SelectedIndex = 2;

                    var beerItem = new BeerItem();

                    var id = new NSObject();
                    info.TryGetValue(new NSString("id"), out id);

                    var name = new NSObject();
                    info.TryGetValue(new NSString("name"), out name);

                    var description = new NSObject();
                    info.TryGetValue(new NSString("description"), out description);

                    var imageUrl = new NSObject();
                    info.TryGetValue(new NSString("imageUrl"), out imageUrl);

                    var breweryDbId = new NSObject();
                    info.TryGetValue(new NSString("breweryDbId"), out breweryDbId);

                    beerItem.Name        = name.ToString();
                    beerItem.Description = description.ToString();
                    beerItem.ImageMedium = imageUrl.ToString();
                    beerItem.BreweryDbId = breweryDbId.ToString();

                    if (!string.IsNullOrEmpty(beerItem.BreweryDbId))
                    {
                        var storyboard = UIStoryboard.FromName("Main", null);
                        var vc         = storyboard.InstantiateViewController("beerDescriptionTableView") as BeerDescriptionTableView;
                        vc.SetBeer(beerItem);
                        var navigationControler = tabController.SelectedViewController as UINavigationController;
                        navigationControler.PushViewController(vc, true);
                    }
                }
                break;
            }

            return(true);
        }
示例#4
0
 public void AddItem(BeerItem beer, int quanity)
 {
     if (_beerBasket.ContainsKey(beer))
     {
         _beerBasket [beer] += _beerBasket [beer];
     }
     else
     {
         _beerBasket.Add(beer, quanity);
     }
 }
示例#5
0
        private async void SearchForBeers(object sender, EventArgs e)
        {
            UserDialogs.Instance.ShowLoading("Searching");
            var response = await indexClient.Documents.SearchAsync <BeerDrinkin.Models.IndexedBeer>(searchBar.Text);

            var beers = new List <BeerItem>();

            foreach (var result in response)
            {
                var beerResult = result.Document;
                if (beerResult != null)
                {
                    var beer = new BeerItem
                    {
                        ABV         = beerResult.Abv,
                        Name        = beerResult.Name,
                        Brewery     = beerResult.BreweryName,
                        Description = beerResult.Description,
                        BreweryDbId = beerResult.Id,
                        BreweryId   = beerResult.BreweryId,
                        Upc         = beerResult.Upc
                    };
                    try
                    {
                        if (beerResult.Images != null || beerResult.Images[0] != null)
                        {
                            beer.ImageLarge  = beerResult.Images[0];
                            beer.ImageMedium = beerResult.Images[1];
                            beer.ImageSmall  = beerResult.Images[2];
                        }
                    }
                    catch (Exception ex)
                    {
                        Insights.Report(ex);
                    }
                    beers.Add(beer);
                }
            }
            var source = new SearchDataSource(beers);

            source.DidSelectBeer += (beer) =>
            {
                selectedBeer = beer;
                PerformSegue("beerDescriptionSegue", this);
                searchResultsTableView.DeselectRow(placeHolderTableView.IndexPathForSelectedRow, true);
            };

            searchResultsTableView.Source = source;
            searchResultsTableView.ReloadData();
            View.BringSubviewToFront(searchResultsTableView);
            UserDialogs.Instance.HideLoading();
        }
        public void SetBeer(BeerItem beer)
        {
            this.beer = beer;

            AddSourceTypeCell();
            if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) == true)
            {
                AddBarcodeCell();
                AddPhotosCell();
            }
            AddRatingCell();
            AddNotesCell();
        }
示例#7
0
 public void RemoveItem(BeerItem beer, int quanity, bool all)
 {
     if (_beerBasket.ContainsKey(beer))
     {
         if (all)
         {
             _beerBasket.Remove(beer);
         }
         else
         {
             _beerBasket [beer] -= quanity;
             if (_beerBasket [beer] <= 0)
             {
                 _beerBasket.Remove(beer);
             }
         }
     }
 }
示例#8
0
        public async Task <IActionResult> GetById(int id)
        {
            var beer = await _db.Beers.Include("Brewery").SingleOrDefaultAsync(b => b.Id == id);

            if (beer == null)
            {
                return(NotFound(new { Message = $"Beer {id} not found" }));
            }

            var beerItem = new BeerItem()
            {
                Name    = beer.Name,
                Brewery = beer.Brewery.Name,
                Abv     = beer.Abv,
                Ibus    = beer.Ibus,
                Style   = beer.Style,
                Id      = beer.Id
            };

            return(Ok(beerItem));
        }
示例#9
0
 async public Task <bool> Flag(BeerItem beerItem)
 {
     return(false);
 }
示例#10
0
 async public Task <bool> Delete(BeerItem beerItem)
 {
     return(false);
 }
示例#11
0
        public void Load(IRace selectedPlayerRace)
        {
            //TODO implement diff levels //-> pass as parameter in methed the level create sweatch for levels and set for mapPath diff map resourse

            var mapPath = AppSettings.MapLevel1;
            var frientFactory = new FriendFactory();
            var enemyFactory = new EnemyFactory();

            this.PlayerRace = selectedPlayerRace;
            var width = AppSettings.MapElementSize.Width;
            var height = AppSettings.MapElementSize.Height;

            try
            {
                using (var reader = new StreamReader(mapPath))
                {
                    for (var row = 0; row < AppSettings.MapElementsCountY; row++)
                    {
                        var top = (row*height)+AppSettings.MapPosition.Top;

                        var line = reader.ReadLine();
                        for (var col = 0; col < AppSettings.MapElementsCountX; col++)
                        {
                            var left = col*width;

                            var currentsymbol = line[col];
                            switch (currentsymbol)
                            {
                                case 'p':
                                    this.Player = new Player(this.PlayerRace)
                                    {
                                        Position = new Position (left, top),
                                        Size = new Size(width, height)
                                    };
                                    break;

                                case 'f':
                                    this.Friend = (Friend)frientFactory.Create(_friendRace);
                                    this.Friend.Position = new Position(left, top);
                                    this.Friend.Size = new Size(width, height);
                                    break;

                                case 'e':
                                    var enemy = (Enemy)enemyFactory.Create(_enemyRace);
                                    enemy.Position = new Position (left, top);
                                    enemy.Size = new Size(width, height);
                                    this.Enemies.Add(enemy);
                                    break;

                                case 'w':
                                    var mazeElement = new MazeItem()
                                    {
                                        Position = new Position(left, top),
                                        Size = new Size(width, height)
                                    };
                                    this.Maze.Add(mazeElement);
                                    break;

                                case 'b':
                                    var beer = new BeerItem()
                                    {
                                        Position = new Position(left, top),
                                        Size = new Size(width, height)
                                    };
                                    this.ItemToCollect.Add(beer);
                                    break;

                                case 'l':
                                    var itemLife = new LifeItem()
                                    {
                                        Position = new Position(left, top),
                                        Size = new Size(width, height)
                                    };
                                    this.ItemToCollect.Add(itemLife);
                                    break;

                                case 'h':
                                    var itemHealth = new LargeHealthItem()
                                    {
                                        Position = new Position(left, top),
                                        Size = new Size(width, height)
                                    };
                                    this.ItemToCollect.Add(itemHealth);
                                    break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "BB Game MapLoader");
            }
        }
示例#12
0
 public void SetBeer(BeerItem item)
 {
     beer = item;
 }