Beispiel #1
0
        public async Task <IActionResult> Park(ParkParkedVehicleViewModel viewModel)
        {
            var parkSpots = ParkingSpotContainer.GetParkSpots(_configuration);

            if (ModelState.IsValid)
            {
                var vehicle = new ParkedVehicle();
                vehicle.VehicleTypeId = int.Parse(Request.Form["Type"].ToString());
                if (vehicle.VehicleTypeId == 0)
                {
                    throw new ArgumentException("The value of the SelectItem selected was zero.");
                }

                var member = TempDataExtensions.Get <Member>(TempData, "member");
                vehicle.MemberId = member.MemberId;
                PopulateVehicleFromViewModel(viewModel, vehicle);
                await ParkVehicleInBackend(parkSpots, vehicle);

                vehicle.IsParked = true;
                _context.Add(vehicle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View());
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("AutoId,AutoKenteken,AutoMerk,AutoType,EigenaarNaam")] Auto auto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(auto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(auto));
        }
        public async Task <IActionResult> Register(MemberRegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var member = mapper.Map <Member>(model);
                _context.Add(member);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }