Ejemplo n.º 1
0
        public IActionResult RentCar([FromForm] RentCarVM vM)
        {
            var listOfCars = carServices.CarList();
            var temp       = new RentCarVM
            {
                _cars = listOfCars.Select(t => new SelectListItem {
                    Selected = t.Id == vM.Id, Value = $"{t.Id}", Text = $"{t.Name}, {t.Model }, Pris per dag: {t.PricePerDay}"
                }).ToList(),
                Car = listOfCars.SingleOrDefault(m => m.Id == vM.Id),
            };
            var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            carServices.AddBooking(temp, userId);
            return(View("SelectedCar", temp));
        }