Exemplo n.º 1
0
        public DietEditPage(DietRecord dietRecord)
        {
            InitializeComponent();
            diet           = dietRecord;
            BindingContext = diet;

            //timePicker.Time = diet.Time;
            //datePicker.Date = diet.Date;
            //descriptionEditor.Text = diet.Description;
            //calEntry.Text = Convert.ToString(diet.Calories);
            //imageEntry.Text = diet.Image;
        }
Exemplo n.º 2
0
        async void OnAddButtonClickedAsync(object sender, System.EventArgs e)
        {
            var diet1 = new DietRecord
            {
                Description = "description is this is lunch, I have beef noddle",
                Calories    = 230,
                Image       = "image1",
                Date        = DateTime.Now,
                Time        = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 0),
                UserId      = App.user.UserId
            };
            //diet1.SetTime();

            await _connection.InsertAsync(diet1);

            _dietRecords.Add(diet1);
        }
Exemplo n.º 3
0
        async public void OnDoneClicked(object sender, EventArgs e)
        {
            var addSucceed = IsAddValid();

            if (addSucceed)
            {
                _connection = DependencyService.Get <ISQLiteDb>().GetConnection();

                await _connection.CreateTableAsync <DietRecord>();

                //var dietRecords = await _connection.Table<DietRecord>().ToListAsync();
                //_dietRecords = new ObservableCollection<DietRecord>(dietRecords);

                //dietRecordListView.ItemsSource = _dietRecords;


                var newDiet = new DietRecord
                {
                    Description = descriptionEditor.Text,
                    Calories    = Convert.ToInt32(calEntry.Text),
                    Image       = imagesPath[0] + ";" + imagesPath[1] + ";" + imagesPath[2],
                    Date        = datePicker.Date,
                    Time        = timePicker.Time,
                    UserId      = App.user.UserId
                };

                newDiet.SetTime();

                await _connection.InsertAsync(newDiet);

                //_dietRecords.Add(newDiet);


                await Navigation.PopToRootAsync();
            }
            else
            {
                message.Text            = "please enter description and enter numbers in calories";
                message.BackgroundColor = Color.Red;
            }
        }