Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Make,Model,AcceptedDate,IsInShop")] Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vehicle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicle));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Name,PartList")] VehicleService vehicleService)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vehicleService);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicleService));
        }
        public async Task <IActionResult> Create(Appointment appointment, List <int> vehicleServices)
        {
            if (ModelState.IsValid)
            {
                _context.Add(appointment);
                await _context.SaveChangesAsync();

                foreach (var service in vehicleServices)
                {
                    _context.Add(new AppointmentVehicleServiceLink()
                    {
                        AppointmentId    = appointment.Id,
                        VehicleServiceId = service
                    });
                }
                await _context.SaveChangesAsync();

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