Example #1
0
        public async Task <IActionResult> AllActivities(HomeActivityViewModel home)
        {
            var userId      = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var usercurrent = _context.Customers.Where(c => c.IdentityUserId == userId).SingleOrDefault();

            ViewBag.UserId = usercurrent.CustomerID;
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:44386/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                ViewBag.country = "";
                HttpResponseMessage response = await client.GetAsync("https://localhost:44386/api/activities");

                if (response.IsSuccessStatusCode)
                {
                    var details = await response.Content.ReadAsAsync <IEnumerable <Activities> >();

                    HomeActivityViewModel homeActivity = new HomeActivityViewModel();
                    homeActivity.Activities = details.Where(a => a.Price <home.MaxBudget &&
                                                                          a.Date> home.dateStart && a.Date < home.dateEnd).ToList();



                    return(View(homeActivity));
                }
                else
                {
                    return(View());
                }
            }
        }
Example #2
0
        public async Task <IActionResult> AllActivities(HomeActivityViewModel home)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:44386/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                ViewBag.country = "";
                HttpResponseMessage response = await client.GetAsync("https://localhost:44386/api/activities");

                if (response.IsSuccessStatusCode)
                {
                    var details = await response.Content.ReadAsAsync <IEnumerable <Activities> >();

                    HomeActivityViewModel homeActivity = new HomeActivityViewModel();
                    homeActivity.Activities = details.Where(a => a.Price <home.MaxBudget &&
                                                                          a.Date> home.dateStart && a.Date < home.dateEnd).ToList();

                    //var ActivitiesList = details.ToList();
                    //var Activity1 = ActivitiesList[0];

                    return(View(homeActivity));
                }
                else
                {
                    return(View());
                }
            }
        }
Example #3
0
        void Init()
        {
            _viewModel = (HomeActivityViewModel) new ViewModelProvider(
                this)
                         .Get(Java.Lang.Class.FromType(typeof(HomeActivityViewModel)));

            _drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            _navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
        }