Esempio n. 1
0
        private int UpdateRecipe(ICollection <Ingredient> _Ingredients, string _Title, string _Description)
        {
            CurrentRecipe.Title       = _Title;
            CurrentRecipe.Description = _Description;

            List <Ingredient> tempList = new List <Ingredient>();

            tempList.AddRange(CurrentRecipe.Ingredients);

            foreach (Ingredient item in _Ingredients)
            {
                if (item.RecipeId != CurrentRecipe.id)
                {
                    item.RecipeId = CurrentRecipe.id;
                    Constants.Conn.Insert(item);
                }
                else
                {
                    tempList.Remove(item);
                }
            }

            foreach (Ingredient item in tempList)
            {
                Constants.Conn.Delete <Ingredient>(item.ID);
            }

            Constants.Conn.Update(CurrentRecipe);

            view.MakeToast(CurrentRecipe.Title + " updated", Android.Widget.ToastLength.Short);
            return(CurrentRecipe.id);
        }
        public void mealPlan_OnClick(int position)
        {
            view.MakeToast("Navigating to: " + mealPlanList[position], ToastLength.Short);

            //TODO lav lige noget intents, når enkelt meal day activity er lavet.
            int id = (Constants.Conn.Get <MealPlan>(position + 1).id);

            view.Navigate(1, new Intent().PutExtra("mealPlanId", id));
        }
Esempio n. 3
0
            public override void OnReceive(Context context, Intent intent)
            {
                if (BluetoothAdapter.ActionDiscoveryStarted.Equals(intent.Action))
                {
                    //discovery started
                    presenter.IsDiscovering = true;
                    view.MakeToast("Discovery started", ToastLength.Short);
                }
                else if (BluetoothAdapter.ActionDiscoveryFinished.Equals(intent.Action))
                {
                    //discovery finished
                    if (presenter.IsDiscovering)
                    {
                        presenter.IsDiscovering = false;
                        view.MakeToast("Discovery finished", ToastLength.Short);
                    }
                }
                else if (BluetoothDevice.ActionFound.Equals(intent.Action))
                {
                    //first lets get the device
                    BluetoothDevice remoteDevice = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);

                    if (remoteDevice != null)
                    {
                        bool addressExists = false;

                        foreach (BluetoothDevice item in presenter.devices)
                        {
                            if (item.Address.Equals(remoteDevice.Address))
                            {
                                addressExists = true;
                            }
                        }

                        if (!addressExists)
                        {
                            presenter.devices.Add(remoteDevice);
                        }
                    }
                }
                view.UpdateView();
            }
        public void ChooseRecipe_OnList(string key)
        {
            //TODO lav exception så man ikke vælger 2 af samme recipe
            try
            {
                pickedRecipeDictionary.Add(key, recipeDictionary.GetValueOrDefault(key));
            }
            catch (System.ArgumentException)
            {
                view.MakeToast("Recipe is already added to day", ToastLength.Short);
            }

            view.UpdateView();
        }
Esempio n. 5
0
 public void hWrite(string text)
 {
     view.MakeToast(text, ToastLength.Short);
 }