// GET: Review/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Search", "Restaurant"));
            }

            Review rev = Mapper.FindReviewByID((int)id);

            if (rev != null)
            {
                ReviewPageViewModel result = new ReviewPageViewModel
                {
                    Review       = rev,
                    RestaurantID = rev.RestaurantID,
                    ReviewerName = ""
                };

                return(View(result));
            }
            else
            {
                return(RedirectToAction("Search", "Restaurant"));
            }
        }
Exemplo n.º 2
0
        public ReviewPage(ReviewPageViewModel rpvm)
        {
            InitializeComponent();

            BindingContext = rpvm;

            listQuestions.ItemTapped += OnListItemTapped;
        }
        // GET: Review/Create/3
        public ActionResult Create(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Search", "Restaurant"));
            }

            Restaurant rest = Mapper.FindRestaurantByID((int)id);

            if (rest != null)
            {
                ReviewPageViewModel result = new ReviewPageViewModel
                {
                    RestaurantID = rest.ID,
                    ReviewerName = ""
                };

                return(View(result));
            }
            else
            {
                return(RedirectToAction("Search", "Restaurant"));
            }
        }
Exemplo n.º 4
0
 public ReviewPage(ReviewPageViewModel viewModel)
 {
     InitializeComponent();
     BindingContext = viewModel;
 }
Exemplo n.º 5
0
		public ReviewPage(ReviewPageViewModel viewModel, TemplateViewModel optionalTemplate = null)
		{
			this.Title = "Review Workouts";
			_viewModel = viewModel;
			if (optionalTemplate != null)
			{
				_viewModel.SimpleExerciseCollection = new ObservableCollection<ExerciseViewModel>();

				var exerciseListTask = WorkoutTemplateMappingDAL.GetMappingsByTemplateID(optionalTemplate.Id);

				Action<Task<List<WorkoutTemplateMapping>>> action = (actionResult) =>
						Device.BeginInvokeOnMainThread(async () =>
						{
							foreach (var mapping in actionResult.Result)
							{
								ExerciseViewModel simpleExercise = new ExerciseViewModel();
								var exercise = await ExerciseDAL.GetExercisesByExerciseID(App.WorkoutCreatorContext.StaffMember.GymID, mapping.ExerciseID);
								if (exercise != null && exercise.Id != 0)
								{
									simpleExercise.Exercise = exercise;
									simpleExercise.ImageSource = exercise.ImageSource;
									simpleExercise.Reps = mapping.Reps;
									simpleExercise.Sets = mapping.Sets;

									//simpleExercise.TargetHRMin = mapping.TargetHRMin;
									//simpleExercise.TargetHRMax = mapping.TargetHRMax;

									simpleExercise.Duration = mapping.TargetDurationMin;
									simpleExercise.IsCardioExercise = exercise.CardioExID != 0 ? true : false;
									_viewModel.SimpleExerciseCollection.Add(simpleExercise);
								}
								else {
									//If exercise is not available manually throw error and log to insights
									try
									{
										throw new Exception("Exercise id " + mapping.ExerciseID.ToString() + "is not in the phone's database");
									}
									catch (Exception e)
									{
										Insights.Report(e);
									}
								}
							}
						});
				exerciseListTask.ContinueWith(action);

			}
			else {
				_viewModel.SimpleExerciseCollection = App.WorkoutCreatorContext.Exercises;
				allowExerciseEdits = true;
			}

			//Add reference of review page view model to each exercise view model
			foreach (var exerciseVM in _viewModel.SimpleExerciseCollection)
			{
				exerciseVM.SimpleExerciseCollection = _viewModel.SimpleExerciseCollection;
			}

			ListView listView = new ListView
			{
				ItemsSource = _viewModel.SimpleExerciseCollection,
				VerticalOptions = LayoutOptions.FillAndExpand,
				RowHeight = 100
			};

			if (allowExerciseEdits)
			{
				listView.ItemTemplate = new DataTemplate(typeof(CustomExerciseImageCell));
				listView.ItemSelected += (sender, args) =>
				{
					if (args.SelectedItem != null)
					{
						listView.SelectedItem = null;

						ExerciseViewModel exercise = (ExerciseViewModel)args.SelectedItem;
						this.Navigation.PushAsync(new ExercisePage(exercise, true, 1, _viewModel.CreateWorkoutOnly, _viewModel.FeedbackOnlyUser));
					}
				};
			}
			else {

				if (allowExerciseDetailsView)
				{
					listView.ItemTemplate = new DataTemplate(typeof(CustomExerciseImageCell));
					listView.ItemSelected += (sender, args) =>
					{
						if (args.SelectedItem != null)
						{
							listView.SelectedItem = null;
							ExerciseViewModel exercise = (ExerciseViewModel)args.SelectedItem;
							this.Navigation.PushAsync(new ExercisePage(exercise, false, 1, _viewModel.CreateWorkoutOnly, _viewModel.FeedbackOnlyUser), true);
						}
					};
				}
				else {
					listView.ItemTemplate = new DataTemplate(typeof(ImageCell));
				}
			}

			listView.ItemTemplate.SetBinding(ImageCell.TextProperty, "Identity");
			listView.ItemTemplate.SetBinding(ImageCell.ImageSourceProperty, "ImageSource");


			this.Content = listView;

		}