Example #1
0
        public ParkingList()
        {
            InitializeComponent();

            if (Device.RuntimePlatform == Device.iOS)
            {
                NavigationPage.SetBackButtonTitle(this, "Back");
            }

            BindingContext = new ParkingListViewModel()
            {
                Navigation = this.Navigation
            };
        }
        public IActionResult GetParking(int id)
        {
            ParkingListViewModel model = new ParkingListViewModel();
            var parking = _context.parkings.Include(p => p.appUser)
                          .FirstOrDefault(p => p.ParkingId == id);

            model.ParkingId   = parking.ParkingId;
            model.PhoneNo     = parking.appUser.PhoneNumber;
            model.NoOfSlot    = parking.Slot;
            model.Address     = parking.Address;
            model.City        = parking.City;
            model.Email       = parking.appUser.Email;
            model.Handlername = parking.appUser.FirstName + parking.appUser.LastName;
            model.Description = parking.Description;
            model.Name        = parking.Name;

            if (parking == null)
            {
                return(NotFound());
            }

            return(new OkObjectResult(model));
        }
        public ActionResult Getparkings()
        {
            List <ParkingListViewModel> Listmodel = new List <ParkingListViewModel>();
            ParkingListViewModel        model     = new ParkingListViewModel();
            var parkings = _context.parkings.Include(p => p.appUser);

            foreach (var park in parkings)
            {
                model = new ParkingListViewModel()
                {
                    ParkingId   = park.ParkingId,
                    City        = park.City,
                    Handlername = park.appUser.FirstName + park.appUser.LastName,
                    Name        = park.Name,
                    NoOfSlot    = park.Slot
                };


                Listmodel.Add(model);
            }

            return(new OkObjectResult(Listmodel));
        }
        //[Route("parkingByName")]
        public async Task <ActionResult <IEnumerable <Parking> > > GetParking(string city)
        {
            List <ParkingListViewModel> listmodel = new List <ParkingListViewModel>();
            ParkingListViewModel        model     = null;
            var result = await _context.parkings.
                         Where(p => p.City == city).
                         ToListAsync();

            foreach (var park in result)
            {
                model = new ParkingListViewModel()
                {
                    Id    = park.ParkingId,
                    Name  = park.Name,
                    City  = park.City,
                    Slot  = park.Slot,
                    Image = park.image
                };

                listmodel.Add(model);
            }

            return(new OkObjectResult(listmodel));
        }
        public SampleParentBindingPage()
        {
            InitializeComponent();

            BindingContext = new ParkingListViewModel();
        }
 public ParkingList(ParkingListViewModel viewModel)
 {
     DataContext = viewModel;
     InitializeComponent();
 }