Example #1
0
 public GoalPage(Model.Goal model, int id)
 {
     InitializeComponent();
     viewModel = new ViewModel.GoalViewModel(model);
     Content.BindingContext = viewModel;
     this.id = id;
 }
Example #2
0
        private async void OnItemTapped(object sender, ItemTappedEventArgs e)
        {
            Model.Goal temp = (Model.Goal)listView.SelectedItem;
            await Navigation.PushAsync(new GoalPage((Model.Goal)e.Item, temp.Id));

            listView.SelectedItem = null;
        }
Example #3
0
 public GoalViewModel(Model.Goal model)
 {
     goal            = model;
     OnAddCommand    = new Command(OnAdd);
     OnSaveCommand   = new Command(OnSave);
     OnUpdateCommand = new Command(OnUpdate);
     OnDeleteCommand = new Command(OnDelete);
 }
Example #4
0
 public GoalViewModel()
 {
     FillListGoalsAsync();
     goal            = new Model.Goal();
     OnAddCommand    = new Command(OnAdd);
     OnSaveCommand   = new Command(OnSave);
     OnUpdateCommand = new Command(OnUpdate);
 }
Example #5
0
 private void OnAdd()
 {
     goal        = new Model.Goal();
     ShortName   = string.Empty;
     Description = string.Empty;
     ReachOn     = DateTime.Today;
     Enable      = false;
 }
Example #6
0
        public Model.Goal Delete(int id)
        {
            //Collect the SQL and call
            string sql = base.LoadSqlResources().Values.First();
            Dictionary <string, object> parameters = ConvertToParameters(new { Id = id });

            Model.Goal removedGoal = typedDataAccess.ExecuteQuery <Model.Goal>(sql, parameters).First();
            return(removedGoal);
        }
Example #7
0
        public Model.Goal GetGoal(int goalID)
        {
            //Collect the SQL and call
            string sql = base.LoadSqlResources().Values.FirstOrDefault();
            Dictionary <string, object> parameters = ConvertToParameters(new { Id = goalID });

            //Load the goal
            Model.Goal goal = typedDataAccess.ExecuteQuery <Model.Goal>(sql, parameters).FirstOrDefault();
            return(goal);
        }
Example #8
0
        public Model.Goal UpdateGoal(int goalId, Model.Goal goal)
        {
            string sql = base.LoadSqlResources().Values.First();
            Dictionary <string, object> parameters = ConvertToParameters
                                                     (
                new
            {
                Id = goalId,
                goal.Name,
                goal.Description,
                goal.Target,
                StatusId = GoalStatus.Open,
                goal.IsDefault
            }
                                                     );

            //Update and return
            return(typedDataAccess.ExecuteQuery <Model.Goal>(sql, parameters).First());
        }
Example #9
0
        public Model.Goal CreateGoalForUser(int userID, Model.Goal goal)
        {
            string sql = base.LoadSqlResources().Values.First();
            Dictionary <string, object> parameters = ConvertToParameters
                                                     (
                new
            {
                UserId = userID,
                goal.Name,
                goal.Description,
                goal.Target,
                StatusId = GoalStatus.Open,
                goal.IsDefault
            }
                                                     );

            //Execute and return the goal
            Model.Goal savedGoal = typedDataAccess.ExecuteQuery <Model.Goal>(sql, parameters).First();
            return(savedGoal);
        }
Example #10
0
 public int UpdateItem(Model.Goal goal)
 {
     return(database.Update(goal));
 }
Example #11
0
 public int SaveItem(Model.Goal item)
 {
     return(database.Insert(item));
 }