コード例 #1
0
        public Task DeleteEmployee(int id)
        {
            var var = _context.Employees.FindAsync(id);

            _context.Employees.Remove(var.Result);
            return(_context.SaveChangesAsync());
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("passportID,No,RegistationDate,Level")] Passport passport)
        {
            if (ModelState.IsValid)
            {
                _context.Add(passport);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(passport));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("BrandId,Name,Description")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                _context.Add(brand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(brand));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("EmployeeID,Email,Name,Surname,passportID")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["passportID"] = new SelectList(_context.Passports, "passportID", "Level", employee.passportID);
            return(View(employee));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("EmployeeID,Age,Address,City,Country")] EmployeeDetails employeeDetails)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employeeDetails);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeID"] = new SelectList(_context.Employees, "EmployeeID", "Name", employeeDetails.EmployeeID);
            return(View(employeeDetails));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("carID,Name,CarImage,Model,price,Year,Run,BrandID")] Car car)
        {
            if (ModelState.IsValid)
            {
                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandID"] = new SelectList(_context.Brands, "BrandId", "Description", car.BrandID);
            return(View(car));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("ID,StartTime,EndTime,EmployeeId,CarId")] RentedCars rentedCars)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rentedCars);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarId"]      = new SelectList(_context.Cars, "carID", "Name", rentedCars.CarId);
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeID", "Name", rentedCars.EmployeeId);
            return(View(rentedCars));
        }