Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,CustomerName,Phonenumber,Email,Age")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Create([Bind("Id,Bike_Name,Model,Make,Year")] Bike bike)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bike);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bike));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Address,Date_of_Birth")] Staff staff)
        {
            if (ModelState.IsValid)
            {
                _context.Add(staff);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(staff));
        }
        public async Task <IActionResult> Create([Bind("Id,CustomerId,StaffId,BikeId")] Buy buy)
        {
            if (ModelState.IsValid)
            {
                _context.Add(buy);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BikeId"]     = new SelectList(_context.Bike, "Id", "Id", buy.BikeId);
            ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "Id", "Id", buy.CustomerId);
            ViewData["StaffId"]    = new SelectList(_context.Set <Staff>(), "Id", "Id", buy.StaffId);
            return(View(buy));
        }