Ejemplo n.º 1
0
 public MyTrips()
 {
     this.InitializeComponent();
     this.ViewModel          = new MyTripsViewModel();
     CreateTripButton.Click += CreateTripButton_Click;
     this.Loaded            += MyTrips_Loaded;
 }
Ejemplo n.º 2
0
        // GET: MyTrips
        public ActionResult Index()
        {
            var allTrips = this.trips
                .GetAll()
                .ToList();
            this.ViewBag.IsDriver = false;

            var attendedTrips = new List<Trip>();
            var createdTrips = new List<Trip>();

            foreach (var trip in allTrips)
            {
                foreach (var passenger in trip.Passengers)
                {
                    if (passenger.Email == this.User.Identity.Name)
                    {
                        attendedTrips.Add(trip);
                    }
                }
            }

            if (this.User.IsInRole("Driver"))
            {
                this.ViewBag.IsDriver = true;

                foreach (var trip in allTrips)
                {
                    if (trip.Driver.UserName == this.User.Identity.Name)
                    {
                        createdTrips.Add(trip);
                    }
                }
            }

            var viewModel = new MyTripsViewModel()
            {
                AttendedTrips = attendedTrips,
                CreatedTrips = createdTrips
            };

            return this.View(viewModel);
        }
Ejemplo n.º 3
0
 public MyTripsView()
 {
     InitializeComponent();
     BindingContext = new MyTripsViewModel(Navigation, ApiService.Instance);
 }